diff options
Diffstat (limited to 'spec/frontend/search/sidebar')
-rw-r--r-- | spec/frontend/search/sidebar/components/archived_filter_spec.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/frontend/search/sidebar/components/archived_filter_spec.js b/spec/frontend/search/sidebar/components/archived_filter_spec.js index 69bf2ebd72e..a4c1f3b758f 100644 --- a/spec/frontend/search/sidebar/components/archived_filter_spec.js +++ b/spec/frontend/search/sidebar/components/archived_filter_spec.js @@ -12,9 +12,14 @@ Vue.use(Vuex); describe('ArchivedFilter', () => { let wrapper; + const defaultActions = { + setQuery: jest.fn(), + }; + const createComponent = (state) => { const store = new Vuex.Store({ state, + actions: defaultActions, }); wrapper = shallowMount(ArchivedFilter, { @@ -70,4 +75,20 @@ describe('ArchivedFilter', () => { expect(findCheckboxFilter().attributes('checked')).toBe(checkboxState); }); }); + + describe('selectedFilter logic', () => { + beforeEach(() => { + createComponent(); + }); + + it('correctly executes setQuery without mutating the input', () => { + const selectedFilter = [false]; + findCheckboxFilter().vm.$emit('input', selectedFilter); + expect(defaultActions.setQuery).toHaveBeenCalledWith(expect.any(Object), { + key: 'include_archived', + value: 'false', + }); + expect(selectedFilter).toEqual([false]); + }); + }); }); |