Commit c7433c81 authored by Winnie Hellmann's avatar Winnie Hellmann

Mock setTargetNoteHash instead of handleHashChanged

parent d8f70c6b
...@@ -10,6 +10,7 @@ import '~/behaviors/markdown/render_gfm'; ...@@ -10,6 +10,7 @@ import '~/behaviors/markdown/render_gfm';
import { setTestTimeout } from 'helpers/timeout'; import { setTestTimeout } from 'helpers/timeout';
// TODO: use generated fixture (https://gitlab.com/gitlab-org/gitlab-foss/issues/62491) // TODO: use generated fixture (https://gitlab.com/gitlab-org/gitlab-foss/issues/62491)
import * as mockData from '../../notes/mock_data'; import * as mockData from '../../notes/mock_data';
import * as urlUtility from '~/lib/utils/url_utility';
setTestTimeout(1000); setTestTimeout(1000);
...@@ -324,11 +325,14 @@ describe('note_app', () => { ...@@ -324,11 +325,14 @@ describe('note_app', () => {
}); });
it('should listen hashchange event', () => { it('should listen hashchange event', () => {
wrapper.vm.$refs.notesApp.handleHashChanged = jest.fn(); const notesApp = wrapper.find(NotesApp);
// jest.spyOn(wrapper.vm.$refs.notesApp, 'handleHashChanged'); const hash = 'some dummy hash';
window.dispatchEvent(new Event('hashchange'), '#foo'); jest.spyOn(urlUtility, 'getLocationHash').mockReturnValueOnce(hash);
const setTargetNoteHash = jest.spyOn(notesApp.vm, 'setTargetNoteHash');
expect(wrapper.vm.$refs.notesApp.handleHashChanged).toHaveBeenCalled(); window.dispatchEvent(new Event('hashchange'), hash);
expect(setTargetNoteHash).toHaveBeenCalled();
}); });
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment