From 415801ded923e3235f45035100415d6bc0a261a7 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:56 +0300 Subject: [PATCH] splitter tests added --- src/components/splitter/Splitter.spec.js | 42 +++++++++++++++++++ .../splitterpanel/SplitterPanel.spec.js | 23 ++++++++++ 2 files changed, 65 insertions(+) create mode 100644 src/components/splitter/Splitter.spec.js create mode 100644 src/components/splitterpanel/SplitterPanel.spec.js diff --git a/src/components/splitter/Splitter.spec.js b/src/components/splitter/Splitter.spec.js new file mode 100644 index 000000000..d9e2788f8 --- /dev/null +++ b/src/components/splitter/Splitter.spec.js @@ -0,0 +1,42 @@ +import { mount } from '@vue/test-utils'; +import Splitter from './Splitter.vue'; +import SplitterPanel from '@/components/splitterpanel/SplitterPanel.vue'; + +describe('Splitter.vue', () => { + let wrapper; + + beforeEach(() => { + wrapper = mount(Splitter, { + global: { + components: { + SplitterPanel + } + }, + slots: { + default: ` + + Panel 1 + + + Panel 2 + + ` + } + }); + }); + + it('should exist', () => { + expect(wrapper.find('.p-splitter.p-component').exists()).toBe(true); + expect(wrapper.find('.p-splitter').classes()).toContain('p-splitter-horizontal'); + expect(wrapper.findAll('.p-splitter-panel').length).toBe(2); + expect(wrapper.find('.p-splitter-gutter-handle').exists()).toBe(true); + }); + + it('should mousedown', async () => { + const gutter = wrapper.find('.p-splitter-gutter-handle').element; + const siblings = wrapper.findAll('.p-splitter-panel'); + await wrapper.vm.onGutterMouseDown({ currentTarget: {gutter, previousElementSibling: siblings[0].element, nextElementSibling: siblings[1].element }, pageX: 123 }, 0); + + expect(wrapper.find('.p-splitter').classes()).toContain('p-splitter-resizing'); + }); +}); \ No newline at end of file diff --git a/src/components/splitterpanel/SplitterPanel.spec.js b/src/components/splitterpanel/SplitterPanel.spec.js new file mode 100644 index 000000000..d1f18461c --- /dev/null +++ b/src/components/splitterpanel/SplitterPanel.spec.js @@ -0,0 +1,23 @@ +import { mount } from '@vue/test-utils'; +import SplitterPanel from './SplitterPanel.vue'; + +describe('SplitterPanel.vue', () => { + let wrapper; + + beforeEach(() => { + wrapper = mount(SplitterPanel, { + attrs: { + class: 'flex align-items-center justify-content-center' + }, + slots: { + default: 'Panel 1' + } + }); + }); + + it('should exist', () => { + expect(wrapper.find('.p-splitter-panel').exists()).toBe(true); + expect(wrapper.attributes().class).toBe('p-splitter-panel flex align-items-center justify-content-center'); + expect(wrapper.find('.p-splitter-panel').text()).toBe('Panel 1'); + }); +}); \ No newline at end of file