debian-mirror-gitlab/spec/frontend/search/store/getters_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

51 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-09-30 23:02:18 +05:30
import { GROUPS_LOCAL_STORAGE_KEY, PROJECTS_LOCAL_STORAGE_KEY } from '~/search/store/constants';
import * as getters from '~/search/store/getters';
import createState from '~/search/store/state';
2023-04-23 21:23:45 +05:30
import {
MOCK_QUERY,
MOCK_GROUPS,
MOCK_PROJECTS,
MOCK_AGGREGATIONS,
MOCK_LANGUAGE_AGGREGATIONS_BUCKETS,
} from '../mock_data';
2021-09-30 23:02:18 +05:30
describe('Global Search Store Getters', () => {
let state;
beforeEach(() => {
state = createState({ query: MOCK_QUERY });
});
describe('frequentGroups', () => {
beforeEach(() => {
state.frequentItems[GROUPS_LOCAL_STORAGE_KEY] = MOCK_GROUPS;
});
it('returns the correct data', () => {
expect(getters.frequentGroups(state)).toStrictEqual(MOCK_GROUPS);
});
});
describe('frequentProjects', () => {
beforeEach(() => {
state.frequentItems[PROJECTS_LOCAL_STORAGE_KEY] = MOCK_PROJECTS;
});
it('returns the correct data', () => {
expect(getters.frequentProjects(state)).toStrictEqual(MOCK_PROJECTS);
});
});
2023-04-23 21:23:45 +05:30
describe('langugageAggregationBuckets', () => {
beforeEach(() => {
state.aggregations.data = MOCK_AGGREGATIONS;
});
it('returns the correct data', () => {
expect(getters.langugageAggregationBuckets(state)).toStrictEqual(
MOCK_LANGUAGE_AGGREGATIONS_BUCKETS,
);
});
});
2021-09-30 23:02:18 +05:30
});