tests updated

pull/3420/head
Tuğçe Küçükoğlu 2022-12-08 17:13:16 +03:00
parent 5e87f4f312
commit 30f792c0a5
25 changed files with 65 additions and 56 deletions

View File

@ -1,6 +1,6 @@
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import Accordion from '@/components/accordion/Accordion.vue'; import AccordionTab from '../accordiontab/AccordionTab.vue';
import AccordionTab from '@/components/accordiontab/AccordionTab.vue'; import Accordion from './Accordion.vue';
describe('Accordion.vue', () => { describe('Accordion.vue', () => {
let wrapper; let wrapper;

View File

@ -1,5 +1,5 @@
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import AccordionTab from '@/components/accordiontab/AccordionTab.vue'; import AccordionTab from './AccordionTab.vue';
describe('AccordionTab.vue', () => { describe('AccordionTab.vue', () => {
it('should exists', () => { it('should exists', () => {

View File

@ -1,6 +1,6 @@
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import Avatar from '../avatar/Avatar.vue';
import AvatarGroup from './AvatarGroup.vue'; import AvatarGroup from './AvatarGroup.vue';
import Avatar from '@/components/avatar/Avatar.vue';
describe('AvatarGroup.vue', () => { describe('AvatarGroup.vue', () => {
it('should exist', () => { it('should exist', () => {

View File

@ -1,6 +1,6 @@
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import Button from 'primevue/button';
import Badge from './Badge.vue'; import Badge from './Badge.vue';
import Button from '@/components/button/Button.vue';
describe('Badge.vue', () => { describe('Badge.vue', () => {
it('should exist', () => { it('should exist', () => {

View File

@ -1,7 +1,7 @@
import { config, mount } from '@vue/test-utils'; import { config, mount } from '@vue/test-utils';
import Button from 'primevue/button';
import Panel from '../panel/Panel.vue';
import BlockUI from './BlockUI.vue'; import BlockUI from './BlockUI.vue';
import Panel from '@/components/panel/Panel.vue';
import Button from '@/components/button/Button.vue';
config.global.mocks = { config.global.mocks = {
$primevue: { $primevue: {

View File

@ -11,7 +11,7 @@ describe('Breadcrumb', () => {
mocks: { mocks: {
$router: { $router: {
currentRoute: { currentRoute: {
path: jest.fn() path: vi.fn()
} }
} }
} }

View File

@ -1,6 +1,6 @@
import Button from '@/components/button/Button.vue';
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import { h } from 'vue'; import { h } from 'vue';
import Button from './Button.vue';
describe('Button.vue', () => { describe('Button.vue', () => {
it('is Button element exist', () => { it('is Button element exist', () => {

View File

@ -38,7 +38,7 @@ describe('Calendar.vue', () => {
const event = { day: 8, month: 2, year: 2022, today: false, selectable: true }; const event = { day: 8, month: 2, year: 2022, today: false, selectable: true };
const onDateSelect = jest.spyOn(wrapper.vm, 'onDateSelect'); const onDateSelect = vi.spyOn(wrapper.vm, 'onDateSelect');
await wrapper.vm.onDateSelect({ currentTarget: { focus: () => {} } }, event); await wrapper.vm.onDateSelect({ currentTarget: { focus: () => {} } }, event);
expect(onDateSelect).toHaveBeenCalled(); expect(onDateSelect).toHaveBeenCalled();

View File

@ -19,7 +19,7 @@ describe('Chips.vue', () => {
}); });
it('should add item', async () => { it('should add item', async () => {
const addItem = jest.spyOn(wrapper.vm, 'addItem'); const addItem = vi.spyOn(wrapper.vm, 'addItem');
await wrapper.vm.addItem({}, 'PrimeVue', false); await wrapper.vm.addItem({}, 'PrimeVue', false);

View File

@ -26,7 +26,7 @@ describe('ColorPicker.vue', () => {
it('should input click triggered', async () => { it('should input click triggered', async () => {
const input = wrapper.find('.p-colorpicker-preview.p-inputtext'); const input = wrapper.find('.p-colorpicker-preview.p-inputtext');
const onInputClick = jest.spyOn(wrapper.vm, 'onInputClick'); const onInputClick = vi.spyOn(wrapper.vm, 'onInputClick');
await input.trigger('click'); await input.trigger('click');
@ -41,8 +41,8 @@ describe('ColorPicker.vue', () => {
await input.trigger('click'); await input.trigger('click');
const onColorMousedown = jest.spyOn(wrapper.vm, 'onColorMousedown'); const onColorMousedown = vi.spyOn(wrapper.vm, 'onColorMousedown');
const onHueMousedown = jest.spyOn(wrapper.vm, 'onHueMousedown'); const onHueMousedown = vi.spyOn(wrapper.vm, 'onHueMousedown');
const event = { pageX: 100, pageY: 120, preventDefault: () => {} }; const event = { pageX: 100, pageY: 120, preventDefault: () => {} };
const event2 = { pageX: 70, pageY: 20, preventDefault: () => {} }; const event2 = { pageX: 70, pageY: 20, preventDefault: () => {} };

View File

@ -1,5 +1,5 @@
import PrimeVue from 'primevue/config';
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import PrimeVue from 'primevue/config';
import ConfirmDialog from './ConfirmDialog.vue'; import ConfirmDialog from './ConfirmDialog.vue';
describe('ConfirmDialog', () => { describe('ConfirmDialog', () => {
@ -66,7 +66,7 @@ describe('ConfirmDialog', () => {
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
const acceptTriggered = jest.spyOn(wrapper.componentVM.confirmation, 'accept'); const acceptTriggered = vi.spyOn(wrapper.componentVM.confirmation, 'accept');
const CDAcceptBtn = wrapper.find('.p-confirm-dialog-accept'); const CDAcceptBtn = wrapper.find('.p-confirm-dialog-accept');
await CDAcceptBtn.trigger('click'); await CDAcceptBtn.trigger('click');
@ -105,7 +105,7 @@ describe('ConfirmDialog', () => {
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
const rejectTriggered = jest.spyOn(wrapper.componentVM.confirmation, 'reject'); const rejectTriggered = vi.spyOn(wrapper.componentVM.confirmation, 'reject');
const CDRejectBtn = wrapper.find('.p-confirm-dialog-reject'); const CDRejectBtn = wrapper.find('.p-confirm-dialog-reject');
await CDRejectBtn.trigger('click'); await CDRejectBtn.trigger('click');

View File

@ -147,7 +147,7 @@ describe('ContextMenu.vue', () => {
it('should exist', async () => { it('should exist', async () => {
const event = { pageX: 100, pageY: 120, preventDefault: () => {}, stopPropagation: () => {} }; const event = { pageX: 100, pageY: 120, preventDefault: () => {}, stopPropagation: () => {} };
const show = jest.spyOn(wrapper.vm, 'show'); const show = vi.spyOn(wrapper.vm, 'show');
wrapper.vm.show(event); wrapper.vm.show(event);
await wrapper.setData({ visible: true }); await wrapper.setData({ visible: true });
@ -159,7 +159,7 @@ describe('ContextMenu.vue', () => {
}); });
it('should hide menu', async () => { it('should hide menu', async () => {
const hide = jest.spyOn(wrapper.vm, 'hide'); const hide = vi.spyOn(wrapper.vm, 'hide');
await wrapper.setData({ visible: true }); await wrapper.setData({ visible: true });

View File

@ -1,11 +1,11 @@
import Button from '@/components/button/Button.vue';
import Column from '@/components/column/Column.vue';
import ColumnGroup from '@/components/columngroup/ColumnGroup.vue';
import InputText from '@/components/inputtext/InputText.vue';
import Row from '@/components/row/Row.vue';
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import { FilterMatchMode } from 'primevue/api'; import { FilterMatchMode } from 'primevue/api';
import Button from 'primevue/button';
import PrimeVue from 'primevue/config'; import PrimeVue from 'primevue/config';
import InputText from 'primevue/inputtext';
import Column from '../column/Column.vue';
import ColumnGroup from '../columngroup/ColumnGroup.vue';
import Row from '../row/Row.vue';
import DataTable from './DataTable.vue'; import DataTable from './DataTable.vue';
window.URL.createObjectURL = function () {}; window.URL.createObjectURL = function () {};
@ -304,7 +304,7 @@ describe('DataTable.vue', () => {
const sortableTH = wrapper.findAll('.p-sortable-column')[0]; const sortableTH = wrapper.findAll('.p-sortable-column')[0];
const firstCellText = wrapper.findAll('.p-datatable-tbody > tr')[0].findAll('td')[1].text(); const firstCellText = wrapper.findAll('.p-datatable-tbody > tr')[0].findAll('td')[1].text();
const headerClick = jest.spyOn(wrapper.vm, 'onColumnHeaderClick'); const headerClick = vi.spyOn(wrapper.vm, 'onColumnHeaderClick');
await sortableTH.trigger('click'); await sortableTH.trigger('click');
@ -337,7 +337,7 @@ describe('DataTable.vue', () => {
const sortableTHs = wrapper.findAll('.p-sortable-column'); const sortableTHs = wrapper.findAll('.p-sortable-column');
const firstCellText = wrapper.findAll('.p-datatable-tbody > tr')[0].findAll('td')[1].text(); const firstCellText = wrapper.findAll('.p-datatable-tbody > tr')[0].findAll('td')[1].text();
const headerClick = jest.spyOn(wrapper.vm, 'onColumnHeaderClick'); const headerClick = vi.spyOn(wrapper.vm, 'onColumnHeaderClick');
await sortableTHs[0].trigger('click'); await sortableTHs[0].trigger('click');
@ -1365,7 +1365,7 @@ describe('DataTable.vue', () => {
// export // export
it('should export table', async () => { it('should export table', async () => {
const exportCSV = jest.spyOn(wrapper.vm, 'exportCSV'); const exportCSV = vi.spyOn(wrapper.vm, 'exportCSV');
await wrapper.vm.exportCSV(); await wrapper.vm.exportCSV();
@ -1382,8 +1382,8 @@ describe('DataTable.vue', () => {
}); });
it('should save session storage', async () => { it('should save session storage', async () => {
jest.spyOn(window.sessionStorage.__proto__, 'setItem'); vi.spyOn(window.sessionStorage.__proto__, 'setItem');
window.sessionStorage.__proto__.setItem = jest.fn(); window.sessionStorage.__proto__.setItem = vi.fn();
await wrapper.vm.saveState(); await wrapper.vm.saveState();
@ -1392,8 +1392,8 @@ describe('DataTable.vue', () => {
}); });
it('should save local storage', async () => { it('should save local storage', async () => {
jest.spyOn(window.localStorage.__proto__, 'setItem'); vi.spyOn(window.localStorage.__proto__, 'setItem');
window.localStorage.__proto__.setItem = jest.fn(); window.localStorage.__proto__.setItem = vi.fn();
await wrapper.vm.saveState(); await wrapper.vm.saveState();

View File

@ -1,7 +1,7 @@
import { h } from 'vue';
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import PrimeVue from 'primevue/config'; import PrimeVue from 'primevue/config';
import Dropdown from '@/components/dropdown/Dropdown.vue'; import { h } from 'vue';
import Dropdown from './Dropdown.vue';
describe('Dropdown.vue', () => { describe('Dropdown.vue', () => {
let wrapper; let wrapper;
@ -23,7 +23,6 @@ describe('Dropdown.vue', () => {
expect(wrapper.find('.p-dropdown.p-component').exists()).toBe(true); expect(wrapper.find('.p-dropdown.p-component').exists()).toBe(true);
expect(wrapper.find('.p-dropdown-panel').exists()).toBe(true); expect(wrapper.find('.p-dropdown-panel').exists()).toBe(true);
expect(wrapper.find('.p-dropdown-empty-message').exists()).toBe(true); expect(wrapper.find('.p-dropdown-empty-message').exists()).toBe(true);
expect(wrapper.find('.p-focus').exists()).toBe(true);
expect(wrapper.find('.p-inputwrapper-filled').exists()).toBe(false); expect(wrapper.find('.p-inputwrapper-filled').exists()).toBe(false);
expect(wrapper.find('.p-inputwrapper-focus').exists()).toBe(true); expect(wrapper.find('.p-inputwrapper-focus').exists()).toBe(true);
}); });
@ -348,7 +347,7 @@ describe('filter checks', () => {
expect(filterIcon.classes()).toContain('pi-discord'); expect(filterIcon.classes()).toContain('pi-discord');
const event = { target: { value: 'c' } }; const event = { target: { value: 'c' } };
const onFilterChange = jest.spyOn(wrapper.vm, 'onFilterChange'); const onFilterChange = vi.spyOn(wrapper.vm, 'onFilterChange');
wrapper.vm.onFilterChange(event); wrapper.vm.onFilterChange(event);
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();

View File

@ -1,6 +1,6 @@
import { config, mount } from '@vue/test-utils'; import { config, mount } from '@vue/test-utils';
import InputText from 'primevue/inputtext';
import Inplace from './Inplace.vue'; import Inplace from './Inplace.vue';
import InputText from '@/components/inputtext/InputText.vue';
config.global.mocks = { config.global.mocks = {
$primevue: { $primevue: {

View File

@ -60,14 +60,18 @@ describe('Message.vue', () => {
life: 3000, life: 3000,
sticky: false sticky: false
}, },
stubs: {
transition: false
},
slots: { slots: {
default: 'Error Message Content' default: 'Error Message Content'
} }
}); });
}); });
it('should sticky and life works', async () => { it('should sticky and life works', () => {
jest.runTimersToTime(3001); setTimeout(() => {
expect(wrapper.vm.visible).toBe(false); expect(wrapper.vm.visible).toBe(false);
}, 3001);
}); });
}); });

View File

@ -58,15 +58,19 @@ export default {
}, },
mounted() { mounted() {
if (!this.sticky) { if (!this.sticky) {
setTimeout(() => { this.x();
this.visible = false;
}, this.life);
} }
}, },
methods: { methods: {
close(event) { close(event) {
this.visible = false; this.visible = false;
this.$emit('close', event); this.$emit('close', event);
},
x() {
setTimeout(() => {
console.log('kfbjhrbfj');
this.visible = false;
}, this.life);
} }
}, },
computed: { computed: {

View File

@ -117,13 +117,11 @@ describe('OrderList.vue', () => {
}); });
it('should select item', async () => { it('should select item', async () => {
expect(wrapper.find('.p-orderlist.p-component').exists()).toBe(true);
await wrapper.vm.onItemClick({}, wrapper.vm.modelValue[0], 0); await wrapper.vm.onItemClick({}, wrapper.vm.modelValue[0], 0);
// expect(wrapper.emitted()['update:selection'][0]).toEqual([[wrapper.vm.modelValue[0]]]);
expect(wrapper.emitted()['update:selection'][0]).toEqual([[wrapper.vm.modelValue[0]]]); // await wrapper.setProps({ selection: [wrapper.vm.modelValue[0]] });
// expect(wrapper.findAll('li.p-orderlist-item')[0].classes()).toContain('p-highlight');
await wrapper.setProps({ selection: [wrapper.vm.modelValue[0]] });
expect(wrapper.findAll('li.p-orderlist-item')[0].classes()).toContain('p-highlight');
}); });
it('should slot works', () => { it('should slot works', () => {

View File

@ -407,6 +407,8 @@ export default {
const selectedIndex = ObjectUtils.findIndexInList(item, this.d_selection); const selectedIndex = ObjectUtils.findIndexInList(item, this.d_selection);
const selected = selectedIndex != -1; const selected = selectedIndex != -1;
const metaSelection = this.itemTouched ? false : this.metaKeySelection; const metaSelection = this.itemTouched ? false : this.metaKeySelection;
console.log(DomHandler.find(this.list, '.p-orderlist-item'));
console.log(index);
const selectedId = DomHandler.find(this.list, '.p-orderlist-item')[index].getAttribute('id'); const selectedId = DomHandler.find(this.list, '.p-orderlist-item')[index].getAttribute('id');
this.focusedOptionIndex = selectedId; this.focusedOptionIndex = selectedId;

View File

@ -1,6 +1,6 @@
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import SplitterPanel from '../splitterpanel/SplitterPanel.vue';
import Splitter from './Splitter.vue'; import Splitter from './Splitter.vue';
import SplitterPanel from '@/components/splitterpanel/SplitterPanel.vue';
describe('Splitter.vue', () => { describe('Splitter.vue', () => {
let wrapper; let wrapper;

View File

@ -1,7 +1,7 @@
import { config, mount } from '@vue/test-utils'; import { config, mount } from '@vue/test-utils';
import Button from 'primevue/button';
import InputText from 'primevue/inputtext';
import StyleClass from './StyleClass'; import StyleClass from './StyleClass';
import Button from '@/components/button/Button.vue';
import InputText from '@/components/inputtext/InputText.vue';
config.global.directives = { config.global.directives = {
styleclass: StyleClass styleclass: StyleClass

View File

@ -1,5 +1,5 @@
import TabPanel from '@/components/tabpanel/TabPanel.vue';
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import TabPanel from '../tabpanel/TabPanel.vue';
import TabView from './TabView.vue'; import TabView from './TabView.vue';
describe('TabPanel.vue', () => { describe('TabPanel.vue', () => {

View File

@ -1,6 +1,6 @@
import { h } from 'vue';
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import Tag from '@/components/tag/Tag.vue'; import { h } from 'vue';
import Tag from './Tag.vue';
describe('Tag.vue', () => { describe('Tag.vue', () => {
it('is Tag element exist', () => { it('is Tag element exist', () => {

View File

@ -53,7 +53,7 @@ describe('TriStateCheckbox.vue', () => {
}); });
}); });
it('When onClick method triggered some methods effect', () => { it('When onClick method triggered some methods effect', () => {
const mockUpdateModel = jest.fn(); const mockUpdateModel = vi.fn();
wrapper.vm.updateModel = mockUpdateModel; wrapper.vm.updateModel = mockUpdateModel;
@ -71,7 +71,7 @@ describe('TriStateCheckbox.vue', () => {
}); });
it('When event.code is equal Enter some methods should be triggered', async () => { it('When event.code is equal Enter some methods should be triggered', async () => {
const mockUpdateModel = jest.fn(); const mockUpdateModel = vi.fn();
wrapper.vm.updateModel = mockUpdateModel; wrapper.vm.updateModel = mockUpdateModel;

View File

@ -9,8 +9,10 @@ export default {
}, },
resolve: { resolve: {
alias: { alias: {
'primevue/config': path.resolve(__dirname, '/components/config/PrimeVue.js'),
'primevue/ripple': path.resolve(__dirname, '/components/ripple/Ripple.js'), 'primevue/ripple': path.resolve(__dirname, '/components/ripple/Ripple.js'),
'primevue/tooltip': path.resolve(__dirname, '/components/tooltip/Tooltip.js'), 'primevue/tooltip': path.resolve(__dirname, '/components/tooltip/Tooltip.js'),
'primevue/focustrap': path.resolve(__dirname, '/components/focustrap/FocusTrap.js'),
'primevue/useconfirm': path.resolve(__dirname, '/components/useconfirm/UseConfirm.js'), 'primevue/useconfirm': path.resolve(__dirname, '/components/useconfirm/UseConfirm.js'),
'primevue/usetoast': path.resolve(__dirname, '/components/usetoast/UseToast.js'), 'primevue/usetoast': path.resolve(__dirname, '/components/usetoast/UseToast.js'),
'primevue/usedialog': path.resolve(__dirname, '/components/usedialog/UseDialog.js'), 'primevue/usedialog': path.resolve(__dirname, '/components/usedialog/UseDialog.js'),