2018-03-23 19:19:29 +08:00
|
|
|
import React from 'react';
|
|
|
|
import { render, mount } from 'enzyme';
|
|
|
|
import Slider from '..';
|
|
|
|
|
|
|
|
describe('Slider', () => {
|
|
|
|
it('should show tooltip when hovering slider handler', () => {
|
2018-12-07 16:17:45 +08:00
|
|
|
const wrapper = mount(<Slider defaultValue={30} />);
|
|
|
|
wrapper
|
|
|
|
.find('.ant-slider-handle')
|
|
|
|
.at(0)
|
|
|
|
.simulate('mouseEnter');
|
|
|
|
expect(
|
|
|
|
render(
|
|
|
|
wrapper
|
|
|
|
.find('Trigger')
|
|
|
|
.instance()
|
|
|
|
.getComponent(),
|
|
|
|
),
|
|
|
|
).toMatchSnapshot();
|
|
|
|
wrapper
|
|
|
|
.find('.ant-slider-handle')
|
|
|
|
.at(0)
|
|
|
|
.simulate('mouseLeave');
|
|
|
|
expect(
|
|
|
|
render(
|
|
|
|
wrapper
|
|
|
|
.find('Trigger')
|
|
|
|
.instance()
|
|
|
|
.getComponent(),
|
|
|
|
),
|
|
|
|
).toMatchSnapshot();
|
2018-03-23 19:19:29 +08:00
|
|
|
});
|
2018-11-01 11:40:47 +08:00
|
|
|
|
|
|
|
it('when tooltipVisible is true, tooltip should show always, or should never show', () => {
|
|
|
|
let wrapper = mount(<Slider defaultValue={30} tooltipVisible />);
|
2018-12-07 16:17:45 +08:00
|
|
|
expect(
|
|
|
|
wrapper
|
|
|
|
.find('.ant-tooltip-content')
|
|
|
|
.at(0)
|
|
|
|
.hasClass('ant-tooltip-hidden'),
|
|
|
|
).toBe(false);
|
|
|
|
wrapper
|
|
|
|
.find('.ant-slider-handle')
|
|
|
|
.at(0)
|
|
|
|
.simulate('mouseEnter');
|
|
|
|
expect(
|
|
|
|
wrapper
|
|
|
|
.find('.ant-tooltip-content')
|
|
|
|
.at(0)
|
|
|
|
.hasClass('ant-tooltip-hidden'),
|
|
|
|
).toBe(false);
|
|
|
|
wrapper
|
|
|
|
.find('.ant-slider-handle')
|
|
|
|
.at(0)
|
|
|
|
.simulate('click');
|
|
|
|
expect(
|
|
|
|
wrapper
|
|
|
|
.find('.ant-tooltip-content')
|
|
|
|
.at(0)
|
|
|
|
.hasClass('ant-tooltip-hidden'),
|
|
|
|
).toBe(false);
|
2018-11-01 11:40:47 +08:00
|
|
|
wrapper = mount(<Slider defaultValue={30} tooltipVisible={false} />);
|
|
|
|
expect(wrapper.find('.ant-tooltip-content').length).toBe(0);
|
|
|
|
});
|
2018-03-23 19:19:29 +08:00
|
|
|
});
|