2016-08-10 08:54:04 -04:00
|
|
|
//= require jquery
|
|
|
|
//= require jquery_ujs
|
|
|
|
//= require jquery.cookie
|
|
|
|
//= require vue
|
|
|
|
//= require vue-resource
|
|
|
|
//= require lib/utils/url_utility
|
|
|
|
//= require boards/models/issue
|
|
|
|
//= require boards/models/label
|
|
|
|
//= require boards/models/list
|
|
|
|
//= require boards/models/user
|
|
|
|
//= require boards/services/board_service
|
|
|
|
//= require boards/stores/boards_store
|
|
|
|
//= require ./mock_data
|
|
|
|
|
|
|
|
(() => {
|
|
|
|
beforeEach(() => {
|
|
|
|
gl.boardService = new BoardService('/test/issue-boards/board');
|
2016-08-15 04:57:01 -04:00
|
|
|
gl.issueBoards.BoardsStore.create();
|
2016-08-10 08:54:04 -04:00
|
|
|
|
|
|
|
$.cookie('issue_board_welcome_hidden', 'false');
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('Store', () => {
|
|
|
|
it('starts with a blank state', () => {
|
2016-08-15 04:57:01 -04:00
|
|
|
expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(0);
|
2016-08-10 08:54:04 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('lists', () => {
|
|
|
|
it('creates new list without persisting to DB', () => {
|
2016-08-15 04:57:01 -04:00
|
|
|
gl.issueBoards.BoardsStore.addList(listObj);
|
2016-08-10 08:54:04 -04:00
|
|
|
|
2016-08-15 04:57:01 -04:00
|
|
|
expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(1);
|
2016-08-10 08:54:04 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('finds list by ID', () => {
|
2016-08-15 04:57:01 -04:00
|
|
|
gl.issueBoards.BoardsStore.addList(listObj);
|
|
|
|
const list = gl.issueBoards.BoardsStore.findList('id', 1);
|
2016-08-10 08:54:04 -04:00
|
|
|
|
|
|
|
expect(list.id).toBe(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('finds list by type', () => {
|
2016-08-15 04:57:01 -04:00
|
|
|
gl.issueBoards.BoardsStore.addList(listObj);
|
|
|
|
const list = gl.issueBoards.BoardsStore.findList('type', 'label');
|
2016-08-10 08:54:04 -04:00
|
|
|
|
|
|
|
expect(list).toBeDefined();
|
|
|
|
});
|
|
|
|
|
2016-08-12 11:58:34 -04:00
|
|
|
it('finds list limited by type', () => {
|
2016-08-15 04:57:01 -04:00
|
|
|
gl.issueBoards.BoardsStore.addList({
|
2016-08-12 11:58:34 -04:00
|
|
|
id: 1,
|
|
|
|
position: 0,
|
|
|
|
title: 'Test',
|
|
|
|
list_type: 'backlog'
|
|
|
|
});
|
2016-08-15 04:57:01 -04:00
|
|
|
const list = gl.issueBoards.BoardsStore.findList('id', 1, 'backlog');
|
2016-08-12 11:58:34 -04:00
|
|
|
|
|
|
|
expect(list).toBeDefined();
|
|
|
|
});
|
|
|
|
|
2016-08-10 08:54:04 -04:00
|
|
|
it('gets issue when new list added', (done) => {
|
2016-08-15 04:57:01 -04:00
|
|
|
gl.issueBoards.BoardsStore.addList(listObj);
|
|
|
|
const list = gl.issueBoards.BoardsStore.findList('id', 1);
|
2016-08-10 08:54:04 -04:00
|
|
|
|
2016-08-15 04:57:01 -04:00
|
|
|
expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(1);
|
2016-08-10 08:54:04 -04:00
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
expect(list.issues.length).toBe(1);
|
2016-08-10 13:29:55 -04:00
|
|
|
expect(list.issues[0].id).toBe(1);
|
2016-08-10 08:54:04 -04:00
|
|
|
done();
|
|
|
|
}, 0);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('persists new list', (done) => {
|
2016-08-15 04:57:01 -04:00
|
|
|
gl.issueBoards.BoardsStore.new({
|
2016-08-10 08:54:04 -04:00
|
|
|
title: 'Test',
|
|
|
|
type: 'label',
|
|
|
|
label: {
|
|
|
|
id: 1,
|
|
|
|
title: 'Testing',
|
|
|
|
color: 'red',
|
|
|
|
description: 'testing;'
|
|
|
|
}
|
|
|
|
});
|
2016-08-15 04:57:01 -04:00
|
|
|
expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(1);
|
2016-08-10 08:54:04 -04:00
|
|
|
|
|
|
|
setTimeout(() => {
|
2016-08-15 04:57:01 -04:00
|
|
|
const list = gl.issueBoards.BoardsStore.findList('id', 1);
|
2016-08-10 08:54:04 -04:00
|
|
|
expect(list).toBeDefined();
|
|
|
|
expect(list.id).toBe(1);
|
|
|
|
expect(list.position).toBe(0);
|
|
|
|
done();
|
|
|
|
}, 0);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('check for blank state adding', () => {
|
2016-08-15 04:57:01 -04:00
|
|
|
expect(gl.issueBoards.BoardsStore.shouldAddBlankState()).toBe(true);
|
2016-08-10 08:54:04 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('check for blank state not adding', () => {
|
2016-08-15 04:57:01 -04:00
|
|
|
gl.issueBoards.BoardsStore.addList(listObj);
|
|
|
|
expect(gl.issueBoards.BoardsStore.shouldAddBlankState()).toBe(false);
|
2016-08-10 08:54:04 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('check for blank state adding when backlog & done list exist', () => {
|
2016-08-15 04:57:01 -04:00
|
|
|
gl.issueBoards.BoardsStore.addList({
|
2016-08-10 08:54:04 -04:00
|
|
|
list_type: 'backlog'
|
|
|
|
});
|
2016-08-15 04:57:01 -04:00
|
|
|
gl.issueBoards.BoardsStore.addList({
|
2016-08-10 08:54:04 -04:00
|
|
|
list_type: 'done'
|
|
|
|
});
|
|
|
|
|
2016-08-15 04:57:01 -04:00
|
|
|
expect(gl.issueBoards.BoardsStore.shouldAddBlankState()).toBe(true);
|
2016-08-10 08:54:04 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('adds the blank state', () => {
|
2016-08-15 04:57:01 -04:00
|
|
|
gl.issueBoards.BoardsStore.addBlankState();
|
2016-08-10 08:54:04 -04:00
|
|
|
|
2016-08-15 04:57:01 -04:00
|
|
|
const list = gl.issueBoards.BoardsStore.findList('type', 'blank', 'blank');
|
2016-08-10 08:54:04 -04:00
|
|
|
expect(list).toBeDefined();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('removes list from state', () => {
|
2016-08-15 04:57:01 -04:00
|
|
|
gl.issueBoards.BoardsStore.addList(listObj);
|
2016-08-10 08:54:04 -04:00
|
|
|
|
2016-08-15 04:57:01 -04:00
|
|
|
expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(1);
|
2016-08-10 08:54:04 -04:00
|
|
|
|
2016-08-16 04:39:58 -04:00
|
|
|
gl.issueBoards.BoardsStore.removeList(1, 'label');
|
2016-08-10 08:54:04 -04:00
|
|
|
|
2016-08-15 04:57:01 -04:00
|
|
|
expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(0);
|
2016-08-10 08:54:04 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('moves the position of lists', () => {
|
2016-08-16 04:39:58 -04:00
|
|
|
const listOne = gl.issueBoards.BoardsStore.addList(listObj),
|
|
|
|
listTwo = gl.issueBoards.BoardsStore.addList(listObjDuplicate);
|
2016-08-10 08:54:04 -04:00
|
|
|
|
2016-08-15 04:57:01 -04:00
|
|
|
expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(2);
|
2016-08-10 08:54:04 -04:00
|
|
|
|
2016-08-16 04:39:58 -04:00
|
|
|
gl.issueBoards.BoardsStore.moveList(listOne, ['2', '1']);
|
2016-08-10 08:54:04 -04:00
|
|
|
|
2016-08-16 04:39:58 -04:00
|
|
|
expect(listOne.position).toBe(1);
|
2016-08-10 08:54:04 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('moves an issue from one list to another', (done) => {
|
2016-08-16 04:39:58 -04:00
|
|
|
const listOne = gl.issueBoards.BoardsStore.addList(listObj),
|
|
|
|
listTwo = gl.issueBoards.BoardsStore.addList(listObjDuplicate);
|
2016-08-10 08:54:04 -04:00
|
|
|
|
2016-08-15 04:57:01 -04:00
|
|
|
expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(2);
|
2016-08-10 08:54:04 -04:00
|
|
|
|
2016-08-10 13:29:55 -04:00
|
|
|
setTimeout(() => {
|
2016-08-16 04:39:58 -04:00
|
|
|
expect(listOne.issues.length).toBe(1);
|
2016-08-10 08:54:04 -04:00
|
|
|
expect(listTwo.issues.length).toBe(1);
|
|
|
|
|
2016-08-16 04:39:58 -04:00
|
|
|
gl.issueBoards.BoardsStore.moveIssueToList(listOne, listTwo, listOne.findIssue(1));
|
2016-08-10 08:54:04 -04:00
|
|
|
|
2016-08-16 04:39:58 -04:00
|
|
|
expect(listOne.issues.length).toBe(0);
|
2016-08-10 08:54:04 -04:00
|
|
|
expect(listTwo.issues.length).toBe(1);
|
|
|
|
|
|
|
|
done();
|
2016-08-10 13:29:55 -04:00
|
|
|
}, 0);
|
2016-08-10 08:54:04 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
})();
|