Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/boards/stores')
-rw-r--r--spec/frontend/boards/stores/actions_spec.js32
-rw-r--r--spec/frontend/boards/stores/mutations_spec.js47
2 files changed, 69 insertions, 10 deletions
diff --git a/spec/frontend/boards/stores/actions_spec.js b/spec/frontend/boards/stores/actions_spec.js
index 0debca1310a..d539cba76ca 100644
--- a/spec/frontend/boards/stores/actions_spec.js
+++ b/spec/frontend/boards/stores/actions_spec.js
@@ -1,6 +1,7 @@
+import testAction from 'helpers/vuex_action_helper';
import actions from '~/boards/stores/actions';
import * as types from '~/boards/stores/mutation_types';
-import testAction from 'helpers/vuex_action_helper';
+import { inactiveId } from '~/boards/constants';
const expectNotImplemented = action => {
it('is not implemented', () => {
@@ -8,19 +9,36 @@ const expectNotImplemented = action => {
});
};
-describe('setEndpoints', () => {
- it('sets endpoints object', () => {
- const mockEndpoints = {
+describe('setInitialBoardData', () => {
+ it('sets data object', () => {
+ const mockData = {
foo: 'bar',
bar: 'baz',
};
return testAction(
- actions.setEndpoints,
- mockEndpoints,
+ actions.setInitialBoardData,
+ mockData,
{},
- [{ type: types.SET_ENDPOINTS, payload: mockEndpoints }],
+ [{ type: types.SET_INITIAL_BOARD_DATA, payload: mockData }],
+ [],
+ );
+ });
+});
+
+describe('setActiveId', () => {
+ it('should commit mutation SET_ACTIVE_ID', done => {
+ const state = {
+ activeId: inactiveId,
+ };
+
+ testAction(
+ actions.setActiveId,
+ 1,
+ state,
+ [{ type: types.SET_ACTIVE_ID, payload: 1 }],
[],
+ done,
);
});
});
diff --git a/spec/frontend/boards/stores/mutations_spec.js b/spec/frontend/boards/stores/mutations_spec.js
index bc57c30b354..c1f7f3dda6e 100644
--- a/spec/frontend/boards/stores/mutations_spec.js
+++ b/spec/frontend/boards/stores/mutations_spec.js
@@ -1,6 +1,6 @@
import mutations from '~/boards/stores/mutations';
-import * as types from '~/boards/stores/mutation_types';
import defaultState from '~/boards/stores/state';
+import { mockIssue } from '../mock_data';
const expectNotImplemented = action => {
it('is not implemented', () => {
@@ -15,7 +15,7 @@ describe('Board Store Mutations', () => {
state = defaultState();
});
- describe('SET_ENDPOINTS', () => {
+ describe('SET_INITIAL_BOARD_DATA', () => {
it('Should set initial Boards data to state', () => {
const endpoints = {
boardsEndpoint: '/boards/',
@@ -25,10 +25,22 @@ describe('Board Store Mutations', () => {
boardId: 1,
fullPath: 'gitlab-org',
};
+ const boardType = 'group';
- mutations[types.SET_ENDPOINTS](state, endpoints);
+ mutations.SET_INITIAL_BOARD_DATA(state, { ...endpoints, boardType });
expect(state.endpoints).toEqual(endpoints);
+ expect(state.boardType).toEqual(boardType);
+ });
+ });
+
+ describe('SET_ACTIVE_ID', () => {
+ it('updates activeListId to be the value that is passed', () => {
+ const expectedId = 1;
+
+ mutations.SET_ACTIVE_ID(state, expectedId);
+
+ expect(state.activeId).toBe(expectedId);
});
});
@@ -68,6 +80,35 @@ describe('Board Store Mutations', () => {
expectNotImplemented(mutations.RECEIVE_REMOVE_LIST_ERROR);
});
+ describe('REQUEST_ISSUES_FOR_ALL_LISTS', () => {
+ it('sets isLoadingIssues to true', () => {
+ expect(state.isLoadingIssues).toBe(false);
+
+ mutations.REQUEST_ISSUES_FOR_ALL_LISTS(state);
+
+ expect(state.isLoadingIssues).toBe(true);
+ });
+ });
+
+ describe('RECEIVE_ISSUES_FOR_ALL_LISTS_SUCCESS', () => {
+ it('sets isLoadingIssues to false and updates issuesByListId object', () => {
+ const listIssues = {
+ '1': [mockIssue],
+ };
+
+ state = {
+ ...state,
+ isLoadingIssues: true,
+ issuesByListId: {},
+ };
+
+ mutations.RECEIVE_ISSUES_FOR_ALL_LISTS_SUCCESS(state, listIssues);
+
+ expect(state.isLoadingIssues).toBe(false);
+ expect(state.issuesByListId).toEqual(listIssues);
+ });
+ });
+
describe('REQUEST_ADD_ISSUE', () => {
expectNotImplemented(mutations.REQUEST_ADD_ISSUE);
});