diff --git a/components/sidebar/Sidebar.spec.js b/components/sidebar/Sidebar.spec.js index 0fe034ceb..3810f725b 100644 --- a/components/sidebar/Sidebar.spec.js +++ b/components/sidebar/Sidebar.spec.js @@ -34,12 +34,12 @@ describe('Sidebar.vue', () => { }); 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'); 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 () => { @@ -52,21 +52,18 @@ describe('Sidebar.vue', () => { expect(focusSpy).toHaveBeenCalled(); }); - it('When transition trigger to onLeave, unbindOutsideClickListener should be triggered', async () => { - const unbindOutsideClickListenerSpy = vi.spyOn(wrapper.vm, 'unbindOutsideClickListener'); - + it('When transition trigger to onLeave, hide should be triggered', async () => { await wrapper.vm.onLeave(); expect(wrapper.emitted().hide.length).toBe(1); - expect(unbindOutsideClickListenerSpy).toHaveBeenCalled(); }); - it('When transition trigger to onAfterEnter, bindOutsideClickListener should be triggered', async () => { - const bindOutsideClickListenerSpy = vi.spyOn(wrapper.vm, 'bindOutsideClickListener'); + it('When transition trigger to onAfterEnter, enableDocumentSettings should be triggered', async () => { + const enableDocumentSettingsSpy = vi.spyOn(wrapper.vm, 'enableDocumentSettings'); await wrapper.vm.onAfterEnter(); - expect(bindOutsideClickListenerSpy).toHaveBeenCalled(); + expect(enableDocumentSettingsSpy).toHaveBeenCalled(); }); it('When keydown is triggered , hide method should be triggered', async () => { @@ -98,7 +95,7 @@ describe('Sidebar.vue', () => { const removeClassSpy = vi.spyOn(DomHandler, 'removeClass'); await wrapper.setProps({ blockScroll: true }); - wrapper.vm.hide(); + wrapper.vm.disableDocumentSettings(); expect(removeClassSpy).toHaveBeenCalled(); }); @@ -107,7 +104,7 @@ describe('Sidebar.vue', () => { const addClassSpy = vi.spyOn(DomHandler, 'addClass'); await wrapper.setProps({ blockScroll: true }); - wrapper.vm.onEnter(); + wrapper.vm.enableDocumentSettings(); expect(addClassSpy).toHaveBeenCalled(); });