diff options
Diffstat (limited to 'spec/frontend/search/store/utils_spec.js')
-rw-r--r-- | spec/frontend/search/store/utils_spec.js | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/spec/frontend/search/store/utils_spec.js b/spec/frontend/search/store/utils_spec.js index bcdad9f89dd..20d764190b1 100644 --- a/spec/frontend/search/store/utils_spec.js +++ b/spec/frontend/search/store/utils_spec.js @@ -1,6 +1,11 @@ import { useLocalStorageSpy } from 'helpers/local_storage_helper'; -import { MAX_FREQUENCY } from '~/search/store/constants'; -import { loadDataFromLS, setFrequentItemToLS, mergeById } from '~/search/store/utils'; +import { MAX_FREQUENCY, SIDEBAR_PARAMS } from '~/search/store/constants'; +import { + loadDataFromLS, + setFrequentItemToLS, + mergeById, + isSidebarDirty, +} from '~/search/store/utils'; import { MOCK_LS_KEY, MOCK_GROUPS, @@ -216,4 +221,24 @@ describe('Global Search Store Utils', () => { }); }); }); + + describe.each` + description | currentQuery | urlQuery | isDirty + ${'identical'} | ${{ [SIDEBAR_PARAMS[0]]: 'default', [SIDEBAR_PARAMS[1]]: 'default' }} | ${{ [SIDEBAR_PARAMS[0]]: 'default', [SIDEBAR_PARAMS[1]]: 'default' }} | ${false} + ${'different'} | ${{ [SIDEBAR_PARAMS[0]]: 'default', [SIDEBAR_PARAMS[1]]: 'new' }} | ${{ [SIDEBAR_PARAMS[0]]: 'default', [SIDEBAR_PARAMS[1]]: 'default' }} | ${true} + ${'null/undefined'} | ${{ [SIDEBAR_PARAMS[0]]: null, [SIDEBAR_PARAMS[1]]: null }} | ${{ [SIDEBAR_PARAMS[0]]: undefined, [SIDEBAR_PARAMS[1]]: undefined }} | ${false} + ${'updated/undefined'} | ${{ [SIDEBAR_PARAMS[0]]: 'new', [SIDEBAR_PARAMS[1]]: 'new' }} | ${{ [SIDEBAR_PARAMS[0]]: undefined, [SIDEBAR_PARAMS[1]]: undefined }} | ${true} + `('isSidebarDirty', ({ description, currentQuery, urlQuery, isDirty }) => { + describe(`with ${description} sidebar query data`, () => { + let res; + + beforeEach(() => { + res = isSidebarDirty(currentQuery, urlQuery); + }); + + it(`returns ${isDirty}`, () => { + expect(res).toStrictEqual(isDirty); + }); + }); + }); }); |