Update Sidebar.spec.js

pull/3539/head
Tuğçe Küçükoğlu 2023-01-16 13:24:50 +03:00
parent 7005c3b51f
commit d3160037e7
1 changed files with 8 additions and 11 deletions

View File

@ -34,12 +34,12 @@ describe('Sidebar.vue', () => {
}); });
it('When mask element triggered, sidebar should be hide', async () => { it('When mask element triggered, sidebar should be hide', async () => {
const unbindOutsideClickListenerSpy = vi.spyOn(wrapper.vm, 'unbindOutsideClickListener'); const hideSpy = vi.spyOn(wrapper.vm, 'hide');
await wrapper.find('.p-sidebar-mask').trigger('mousedown'); await wrapper.find('.p-sidebar-mask').trigger('mousedown');
expect(wrapper.emitted()['update:visible'].length).toBe(1); expect(wrapper.emitted()['update:visible'].length).toBe(1);
expect(unbindOutsideClickListenerSpy).toHaveBeenCalled(); expect(hideSpy).toHaveBeenCalled();
}); });
it('When transition trigger to onEnter, sidebar should be visible', async () => { it('When transition trigger to onEnter, sidebar should be visible', async () => {
@ -52,21 +52,18 @@ describe('Sidebar.vue', () => {
expect(focusSpy).toHaveBeenCalled(); expect(focusSpy).toHaveBeenCalled();
}); });
it('When transition trigger to onLeave, unbindOutsideClickListener should be triggered', async () => { it('When transition trigger to onLeave, hide should be triggered', async () => {
const unbindOutsideClickListenerSpy = vi.spyOn(wrapper.vm, 'unbindOutsideClickListener');
await wrapper.vm.onLeave(); await wrapper.vm.onLeave();
expect(wrapper.emitted().hide.length).toBe(1); expect(wrapper.emitted().hide.length).toBe(1);
expect(unbindOutsideClickListenerSpy).toHaveBeenCalled();
}); });
it('When transition trigger to onAfterEnter, bindOutsideClickListener should be triggered', async () => { it('When transition trigger to onAfterEnter, enableDocumentSettings should be triggered', async () => {
const bindOutsideClickListenerSpy = vi.spyOn(wrapper.vm, 'bindOutsideClickListener'); const enableDocumentSettingsSpy = vi.spyOn(wrapper.vm, 'enableDocumentSettings');
await wrapper.vm.onAfterEnter(); await wrapper.vm.onAfterEnter();
expect(bindOutsideClickListenerSpy).toHaveBeenCalled(); expect(enableDocumentSettingsSpy).toHaveBeenCalled();
}); });
it('When keydown is triggered , hide method should be triggered', async () => { it('When keydown is triggered , hide method should be triggered', async () => {
@ -98,7 +95,7 @@ describe('Sidebar.vue', () => {
const removeClassSpy = vi.spyOn(DomHandler, 'removeClass'); const removeClassSpy = vi.spyOn(DomHandler, 'removeClass');
await wrapper.setProps({ blockScroll: true }); await wrapper.setProps({ blockScroll: true });
wrapper.vm.hide(); wrapper.vm.disableDocumentSettings();
expect(removeClassSpy).toHaveBeenCalled(); expect(removeClassSpy).toHaveBeenCalled();
}); });
@ -107,7 +104,7 @@ describe('Sidebar.vue', () => {
const addClassSpy = vi.spyOn(DomHandler, 'addClass'); const addClassSpy = vi.spyOn(DomHandler, 'addClass');
await wrapper.setProps({ blockScroll: true }); await wrapper.setProps({ blockScroll: true });
wrapper.vm.onEnter(); wrapper.vm.enableDocumentSettings();
expect(addClassSpy).toHaveBeenCalled(); expect(addClassSpy).toHaveBeenCalled();
}); });