ant-design-vue/components/slider/__tests__/index.test.js
2020-07-25 15:46:49 +08:00

54 lines
1.3 KiB
JavaScript

import { mount } from '@vue/test-utils';
import { asyncExpect } from '@/tests/utils';
import Slider from '..';
import mountTest from '../../../tests/shared/mountTest';
describe('Slider', () => {
mountTest(Slider);
it('should show tooltip when hovering slider handler', async () => {
const wrapper = mount(Slider, {
props: {
defaultValue: 30,
},
sync: false,
});
await asyncExpect(() => {
wrapper
.findAll('.ant-slider-handle')
.at(0)
.trigger('mouseenter');
});
let dropdownWrapper = null;
await asyncExpect(() => {
dropdownWrapper = mount(
{
render() {
return wrapper.find({ name: 'Trigger' }).vm.getComponent();
},
},
{ sync: false },
);
});
await asyncExpect(() => {
expect(dropdownWrapper.html()).toMatchSnapshot();
wrapper
.findAll('.ant-slider-handle')
.at(0)
.trigger('mouseleave');
});
await asyncExpect(() => {
dropdownWrapper = mount(
{
render() {
return wrapper.find({ name: 'Trigger' }).vm.getComponent();
},
},
{ sync: false },
);
});
await asyncExpect(() => {
expect(dropdownWrapper.html()).toMatchSnapshot();
});
});
});