From df1a0ad1c8187bab9778f49390b9ae9527205471 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:46:09 +0300 Subject: [PATCH] Create TabView.spec.js --- src/components/tabview/TabView.spec.js | 48 ++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/components/tabview/TabView.spec.js diff --git a/src/components/tabview/TabView.spec.js b/src/components/tabview/TabView.spec.js new file mode 100644 index 000000000..f5aefadbb --- /dev/null +++ b/src/components/tabview/TabView.spec.js @@ -0,0 +1,48 @@ +import { mount } from '@vue/test-utils'; +import TabView from './TabView.vue'; +import TabPanel from '@/components/tabpanel/TabPanel.vue'; + +describe('TabPanel.vue', () => { + let wrapper; + + window.HTMLElement.prototype.scrollIntoView = function() {}; + + beforeEach(() => { + wrapper = mount(TabView, { + global: { + components: { + TabPanel + } + }, + slots: { + default: ` + +

Lorem ipsum dolor sit amet, consectetur adipiscing elit,

+
+ +

Sed ut perspiciatis unde omnis iste natus error sit voluptatem

+
+ +

At vero eos et accusamus et iusto odio dignissimos ducimus qui

+
+ ` + } + }); + }); + + it('should exist', () => { + expect(wrapper.find('.p-tabview.p-component').exists()).toBe(true); + expect(wrapper.find('.p-tabview-ink-bar').exists()).toBe(true); + expect(wrapper.findAll('a.p-tabview-nav-link').length).toBe(3); + expect(wrapper.findAll('.p-tabview-panel').length).toBe(3); + expect(wrapper.findAll('li[role="presentation"]')[0].classes()).toContain('p-highlight'); + expect(wrapper.findAll('.p-tabview-panel')[1].attributes().style).toBe('display: none;'); + }); + + it('should change the active item', async () => { + await wrapper.vm.onTabClick({}, 1); + + expect(wrapper.findAll('li[role="presentation"]')[1].classes()).toContain('p-highlight'); + expect(wrapper.findAll('.p-tabview-panel')[0].attributes().style).toBe('display: none;'); + }); +}); \ No newline at end of file