diff options
Diffstat (limited to 'spec/frontend/notes/components/sort_discussion_spec.js')
-rw-r--r-- | spec/frontend/notes/components/sort_discussion_spec.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/frontend/notes/components/sort_discussion_spec.js b/spec/frontend/notes/components/sort_discussion_spec.js index 724c77eee3d..575f1057db2 100644 --- a/spec/frontend/notes/components/sort_discussion_spec.js +++ b/spec/frontend/notes/components/sort_discussion_spec.js @@ -1,6 +1,7 @@ import { shallowMount, createLocalVue } from '@vue/test-utils'; import Vuex from 'vuex'; import SortDiscussion from '~/notes/components/sort_discussion.vue'; +import LocalStorageSync from '~/vue_shared/components/local_storage_sync.vue'; import createStore from '~/notes/stores'; import { ASC, DESC } from '~/notes/constants'; import Tracking from '~/tracking'; @@ -21,6 +22,8 @@ describe('Sort Discussion component', () => { }); }; + const findLocalStorageSync = () => wrapper.find(LocalStorageSync); + beforeEach(() => { store = createStore(); jest.spyOn(Tracking, 'event'); @@ -31,6 +34,22 @@ describe('Sort Discussion component', () => { wrapper = null; }); + describe('default', () => { + beforeEach(() => { + createComponent(); + }); + + it('has local storage sync', () => { + expect(findLocalStorageSync().exists()).toBe(true); + }); + + it('calls setDiscussionSortDirection when update is emitted', () => { + findLocalStorageSync().vm.$emit('input', ASC); + + expect(store.dispatch).toHaveBeenCalledWith('setDiscussionSortDirection', ASC); + }); + }); + describe('when asc', () => { describe('when the dropdown is clicked', () => { it('calls the right actions', () => { |