diff options
Diffstat (limited to 'spec/frontend/notes/mixins/discussion_navigation_spec.js')
-rw-r--r-- | spec/frontend/notes/mixins/discussion_navigation_spec.js | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/spec/frontend/notes/mixins/discussion_navigation_spec.js b/spec/frontend/notes/mixins/discussion_navigation_spec.js index ecff95b6fe0..11c0bbfefc9 100644 --- a/spec/frontend/notes/mixins/discussion_navigation_spec.js +++ b/spec/frontend/notes/mixins/discussion_navigation_spec.js @@ -1,11 +1,11 @@ import Vuex from 'vuex'; import { shallowMount, createLocalVue } from '@vue/test-utils'; +import { setHTMLFixture } from 'helpers/fixtures'; import * as utils from '~/lib/utils/common_utils'; import discussionNavigation from '~/notes/mixins/discussion_navigation'; import eventHub from '~/notes/event_hub'; import createEventHub from '~/helpers/event_hub_factory'; import notesModule from '~/notes/stores/modules'; -import { setHTMLFixture } from 'helpers/fixtures'; const discussion = (id, index) => ({ id, @@ -66,6 +66,35 @@ describe('Discussion navigation mixin', () => { const findDiscussion = (selector, id) => document.querySelector(`${selector}[data-discussion-id="${id}"]`); + describe('jumpToFirstUnresolvedDiscussion method', () => { + let vm; + + beforeEach(() => { + createComponent(); + + ({ vm } = wrapper); + + jest.spyOn(store, 'dispatch'); + jest.spyOn(vm, 'jumpToNextDiscussion'); + }); + + it('triggers the setCurrentDiscussionId action with null as the value', () => { + vm.jumpToFirstUnresolvedDiscussion(); + + expect(store.dispatch).toHaveBeenCalledWith('setCurrentDiscussionId', null); + }); + + it('triggers the jumpToNextDiscussion action when the previous store action succeeds', () => { + store.dispatch.mockResolvedValue(); + + vm.jumpToFirstUnresolvedDiscussion(); + + return vm.$nextTick().then(() => { + expect(vm.jumpToNextDiscussion).toHaveBeenCalled(); + }); + }); + }); + describe('cycle through discussions', () => { beforeEach(() => { window.mrTabs = { eventHub: createEventHub(), tabShown: jest.fn() }; |