diff options
Diffstat (limited to 'spec/frontend/notes/components/note_app_spec.js')
-rw-r--r-- | spec/frontend/notes/components/note_app_spec.js | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/spec/frontend/notes/components/note_app_spec.js b/spec/frontend/notes/components/note_app_spec.js index a8ec47fd44f..3716b349210 100644 --- a/spec/frontend/notes/components/note_app_spec.js +++ b/spec/frontend/notes/components/note_app_spec.js @@ -9,7 +9,8 @@ import createStore from '~/notes/stores'; 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 '../../../javascripts/notes/mock_data'; +import * as mockData from '../../notes/mock_data'; +import * as urlUtility from '~/lib/utils/url_utility'; setTestTimeout(1000); @@ -54,7 +55,9 @@ describe('note_app', () => { components: { NotesApp, }, - template: '<div class="js-vue-notes-event"><notes-app v-bind="$attrs" /></div>', + template: `<div class="js-vue-notes-event"> + <notes-app ref="notesApp" v-bind="$attrs" /> + </div>`, }, { attachToDocument: true, @@ -313,4 +316,23 @@ describe('note_app', () => { }); }); }); + + describe('mounted', () => { + beforeEach(() => { + axiosMock.onAny().reply(mockData.getIndividualNoteResponse); + wrapper = mountComponent(); + return waitForDiscussionsRequest(); + }); + + it('should listen hashchange event', () => { + const notesApp = wrapper.find(NotesApp); + const hash = 'some dummy hash'; + jest.spyOn(urlUtility, 'getLocationHash').mockReturnValueOnce(hash); + const setTargetNoteHash = jest.spyOn(notesApp.vm, 'setTargetNoteHash'); + + window.dispatchEvent(new Event('hashchange'), hash); + + expect(setTargetNoteHash).toHaveBeenCalled(); + }); + }); }); |