Create Slider.spec.js

pull/2402/head
Tuğçe Küçükoğlu 2022-04-05 17:45:26 +03:00
parent 76364423f7
commit 9b132c48f8
1 changed files with 49 additions and 0 deletions

View File

@ -0,0 +1,49 @@
import { mount } from '@vue/test-utils';
import Slider from './Slider.vue';
describe('Slider.vue', () => {
let wrapper;
beforeEach(() => {
wrapper = mount(Slider, {
props: {
modelValue: null
}
});
});
it('should exist', () => {
expect(wrapper.find('.p-slider.p-component').exists()).toBe(true);
expect(wrapper.find('.p-slider').classes()).toContain('p-slider-horizontal');
});
it('should drag start and end', async () => {
await wrapper.vm.onDragStart({ preventDefault: () => {} });
expect(wrapper.find('.p-slider').classes()).toContain('p-slider-sliding');
await wrapper.vm.onDragEnd();
expect(wrapper.find('.p-slider').classes()).not.toContain('p-slider-sliding');
});
it('should set value', async () => {
wrapper.element.setAttribute('width', '14rem');
await wrapper.vm.updateDomData();
await wrapper.vm.setValue({ pageX: 60 }); // TODO:
expect(wrapper.emitted()['update:modelValue'][0][0]).toBeGreaterThan(0);
});
it('should set value on vertical mode', async () => {
await wrapper.setProps({ orientation: 'vertical', modelValue: 0 });
await wrapper.vm.updateDomData();
await wrapper.vm.setValue({ pageY: 111 }); // TODO:
expect(wrapper.emitted()['update:modelValue'][0][0]).toBeGreaterThan(0);
});
});