Commit da378c6b authored by Winnie Hellmann's avatar Winnie Hellmann Committed by Fatih Acet

Move setCurrentBoard() from BoardsStoreEE to core

parent df43b144
......@@ -374,6 +374,10 @@ const boardsStore = {
deleteBoard({ id }) {
return axios.delete(this.generateBoardsPath(id));
},
setCurrentBoard(board) {
this.state.currentBoard = board;
},
};
BoardsStoreEE.initEESpecific(boardsStore);
......
......@@ -15,11 +15,17 @@ class BoardsStoreEE {
this.addPromotion();
};
this.store.loadList = (listPath, listType) => this.loadList(listPath, listType);
this.store.setCurrentBoard = board => this.setCurrentBoard(board);
this.store.removePromotionState = () => {
this.removePromotion();
};
const superSetCurrentBoard = this.store.setCurrentBoard.bind(this.store);
this.store.setCurrentBoard = board => {
superSetCurrentBoard(board);
this.store.state.assignees = [];
this.store.state.milestones = [];
};
const baseCreate = this.store.create.bind(this.store);
this.store.create = () => {
baseCreate();
......@@ -166,13 +172,6 @@ class BoardsStoreEE {
return parseBoolean(Cookies.get('promotion_issue_board_hidden'));
}
setCurrentBoard(board) {
const { state } = this.store;
state.currentBoard = board;
state.assignees = [];
state.milestones = [];
}
updateWeight(newWeight, id) {
const { issue } = this.store.detail;
if (issue.id === id && issue.sidebarInfoEndpoint) {
......
......@@ -7,15 +7,19 @@ import { TEST_HOST } from 'helpers/test_constants';
jest.mock('~/flash');
describe('BoardsStoreEE', () => {
let setCurrentBoard;
let axiosMock;
beforeEach(() => {
axiosMock = new AxiosMockAdapter(axios);
setCurrentBoard = jest.fn();
// mock CE store
const storeMock = {
state: {},
create() {},
setCurrentBoard,
};
BoardsStoreEE.initEESpecific(storeMock);
......@@ -60,20 +64,17 @@ describe('BoardsStoreEE', () => {
describe('setCurrentBoard', () => {
const dummyBoard = 'skateboard';
it('sets the current board', () => {
const { state } = BoardsStoreEE.store;
state.currentBoard = null;
BoardsStoreEE.setCurrentBoard(dummyBoard);
it('calls setCurrentBoard() of the base store', () => {
BoardsStoreEE.store.setCurrentBoard(dummyBoard);
expect(state.currentBoard).toEqual(dummyBoard);
expect(setCurrentBoard).toHaveBeenCalledWith(dummyBoard);
});
it('resets assignees', () => {
const { state } = BoardsStoreEE.store;
state.assignees = 'some assignees';
BoardsStoreEE.setCurrentBoard(dummyBoard);
BoardsStoreEE.store.setCurrentBoard(dummyBoard);
expect(state.assignees).toEqual([]);
});
......@@ -82,7 +83,7 @@ describe('BoardsStoreEE', () => {
const { state } = BoardsStoreEE.store;
state.milestones = 'some milestones';
BoardsStoreEE.setCurrentBoard(dummyBoard);
BoardsStoreEE.store.setCurrentBoard(dummyBoard);
expect(state.milestones).toEqual([]);
});
......
......@@ -365,4 +365,17 @@ describe('Store', () => {
expect(boardsStore.timeTracking.limitToHours).toEqual(true);
});
});
describe('setCurrentBoard', () => {
const dummyBoard = 'hoverboard';
it('sets the current board', () => {
const { state } = boardsStore;
state.currentBoard = null;
boardsStore.setCurrentBoard(dummyBoard);
expect(state.currentBoard).toEqual(dummyBoard);
});
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment