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';
import { setTestTimeout } from 'helpers/timeout';
// TODO: use generated fixture (https://gitlab.com/gitlab-org/gitlab-foss/issues/62491)
import * as mockData from '../../notes/mock_data';
import * as urlUtility from '~/lib/utils/url_utility';
setTestTimeout(1000);
......@@ -324,11 +325,14 @@ describe('note_app', () => {
});
it('should listen hashchange event', () => {
wrapper.vm.$refs.notesApp.handleHashChanged = jest.fn();
// jest.spyOn(wrapper.vm.$refs.notesApp, 'handleHashChanged');
window.dispatchEvent(new Event('hashchange'), '#foo');
const notesApp = wrapper.find(NotesApp);
const hash = 'some dummy hash';
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