From 9b132c48f8e5f4ae14d4e1bf82079bff4a8e7775 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=C4=9F=C3=A7e=20K=C3=BC=C3=A7=C3=BCko=C4=9Flu?= Date: Tue, 5 Apr 2022 17:45:26 +0300 Subject: [PATCH] Create Slider.spec.js --- src/components/slider/Slider.spec.js | 49 ++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/components/slider/Slider.spec.js diff --git a/src/components/slider/Slider.spec.js b/src/components/slider/Slider.spec.js new file mode 100644 index 000000000..fdb600a4e --- /dev/null +++ b/src/components/slider/Slider.spec.js @@ -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); + }); +}); \ No newline at end of file