summaryrefslogtreecommitdiff
path: root/spec/frontend/search/store/mutations_spec.js
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-11-19 08:27:35 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-11-19 08:27:35 +0000
commit7e9c479f7de77702622631cff2628a9c8dcbc627 (patch)
treec8f718a08e110ad7e1894510980d2155a6549197 /spec/frontend/search/store/mutations_spec.js
parente852b0ae16db4052c1c567d9efa4facc81146e88 (diff)
downloadgitlab-ce-7e9c479f7de77702622631cff2628a9c8dcbc627.tar.gz
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/frontend/search/store/mutations_spec.js')
-rw-r--r--spec/frontend/search/store/mutations_spec.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/frontend/search/store/mutations_spec.js b/spec/frontend/search/store/mutations_spec.js
new file mode 100644
index 00000000000..28d9646b97e
--- /dev/null
+++ b/spec/frontend/search/store/mutations_spec.js
@@ -0,0 +1,48 @@
+import mutations from '~/search/store/mutations';
+import createState from '~/search/store/state';
+import * as types from '~/search/store/mutation_types';
+import { MOCK_QUERY, MOCK_GROUPS } from '../mock_data';
+
+describe('Global Search Store Mutations', () => {
+ let state;
+
+ beforeEach(() => {
+ state = createState({ query: MOCK_QUERY });
+ });
+
+ describe('REQUEST_GROUPS', () => {
+ it('sets fetchingGroups to true', () => {
+ mutations[types.REQUEST_GROUPS](state);
+
+ expect(state.fetchingGroups).toBe(true);
+ });
+ });
+
+ describe('RECEIVE_GROUPS_SUCCESS', () => {
+ it('sets fetchingGroups to false and sets groups', () => {
+ mutations[types.RECEIVE_GROUPS_SUCCESS](state, MOCK_GROUPS);
+
+ expect(state.fetchingGroups).toBe(false);
+ expect(state.groups).toBe(MOCK_GROUPS);
+ });
+ });
+
+ describe('RECEIVE_GROUPS_ERROR', () => {
+ it('sets fetchingGroups to false and clears groups', () => {
+ mutations[types.RECEIVE_GROUPS_ERROR](state);
+
+ expect(state.fetchingGroups).toBe(false);
+ expect(state.groups).toEqual([]);
+ });
+ });
+
+ describe('SET_QUERY', () => {
+ const payload = { key: 'key1', value: 'value1' };
+
+ it('sets query key to value', () => {
+ mutations[types.SET_QUERY](state, payload);
+
+ expect(state.query[payload.key]).toBe(payload.value);
+ });
+ });
+});