diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-19 03:09:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-19 03:09:42 +0300 |
commit | 91d37b971433b16c25ec501429ac643f9c49839e (patch) | |
tree | 59ced702b47ff50a967653e2207f5a602513dca1 /spec/frontend/header_search/init_spec.js | |
parent | 540020f8155ff0686ae9a51a16414661e3cdaf9d (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/header_search/init_spec.js')
-rw-r--r-- | spec/frontend/header_search/init_spec.js | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/spec/frontend/header_search/init_spec.js b/spec/frontend/header_search/init_spec.js index 2feef79e8d1..9515ca8c812 100644 --- a/spec/frontend/header_search/init_spec.js +++ b/spec/frontend/header_search/init_spec.js @@ -1,6 +1,6 @@ import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures'; -import initHeaderSearch, { eventHandler } from '~/header_search/init'; +import initHeaderSearch, { eventHandler, cleanEventListeners } from '~/header_search/init'; describe('Header Search EventListener', () => { beforeEach(() => { @@ -21,24 +21,25 @@ describe('Header Search EventListener', () => { it('attached event listener', () => { const searchInputBox = document?.querySelector('#search'); - const addEventListener = jest.spyOn(searchInputBox, 'addEventListener'); + const addEventListenerSpy = jest.spyOn(searchInputBox, 'addEventListener'); initHeaderSearch(); - expect(addEventListener).toBeCalled(); + expect(addEventListenerSpy).toBeCalledTimes(2); }); it('removes event listener ', async () => { - const removeEventListener = jest.fn(); + const searchInputBox = document?.querySelector('#search'); + const removeEventListenerSpy = jest.spyOn(searchInputBox, 'removeEventListener'); jest.mock('~/header_search', () => ({ initHeaderSearchApp: jest.fn() })); await eventHandler.apply( { newHeaderSearchFeatureFlag: true, searchInputBox: document.querySelector('#search'), }, - [removeEventListener], + [cleanEventListeners], ); - expect(removeEventListener).toBeCalled(); + expect(removeEventListenerSpy).toBeCalledTimes(2); }); it('attaches new vue dropdown when feature flag is enabled', async () => { |