Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
c16d5bcd
Commit
c16d5bcd
authored
Nov 05, 2016
by
winniehell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move Ajax interceptor into describe block (!7304)
parent
50f3fd49
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
116 additions
and
108 deletions
+116
-108
spec/javascripts/boards/boards_store_spec.js.es6
spec/javascripts/boards/boards_store_spec.js.es6
+109
-106
spec/javascripts/boards/list_spec.js.es6
spec/javascripts/boards/list_spec.js.es6
+5
-0
spec/javascripts/boards/mock_data.js.es6
spec/javascripts/boards/mock_data.js.es6
+2
-2
No files found.
spec/javascripts/boards/boards_store_spec.js.es6
View file @
c16d5bcd
...
@@ -13,8 +13,9 @@
...
@@ -13,8 +13,9 @@
//= require boards/stores/boards_store
//= require boards/stores/boards_store
//= require ./mock_data
//= require ./mock_data
(
() => {
describe('Store',
() => {
beforeEach(() => {
beforeEach(() => {
Vue.http.interceptors.push(boardsMockInterceptor);
gl.boardService = new BoardService('/test/issue-boards/board', '1');
gl.boardService = new BoardService('/test/issue-boards/board', '1');
gl.issueBoards.BoardsStore.create();
gl.issueBoards.BoardsStore.create();
...
@@ -24,145 +25,147 @@
...
@@ -24,145 +25,147 @@
});
});
});
});
describe('Store', () => {
afterEach(() => {
it('starts with a blank state', () => {
Vue.http.interceptors = _.without(Vue.http.interceptors, boardsMockInterceptor);
expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(0);
});
});
describe('lists
', () => {
it('starts with a blank state
', () => {
it('creates new list without persisting to DB', () => {
expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(0);
gl.issueBoards.BoardsStore.addList(listObj
);
}
);
expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(1);
describe('lists', () => {
});
it('creates new list without persisting to DB', () => {
gl.issueBoards.BoardsStore.addList(listObj);
it('finds list by ID', () => {
expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(1);
gl.issueBoards.BoardsStore.addList(listObj);
});
const list = gl.issueBoards.BoardsStore.findList('id', 1);
expect(list.id).toBe(1);
it('finds list by ID', () => {
});
gl.issueBoards.BoardsStore.addList(listObj);
const list = gl.issueBoards.BoardsStore.findList('id', 1);
it('finds list by type', () => {
expect(list.id).toBe(1);
gl.issueBoards.BoardsStore.addList(listObj);
});
const list = gl.issueBoards.BoardsStore.findList('type', 'label');
expect(list).toBeDefined();
it('finds list by type', () => {
});
gl.issueBoards.BoardsStore.addList(listObj);
const list = gl.issueBoards.BoardsStore.findList('type', 'label');
it('finds list limited by type', () => {
expect(list).toBeDefined();
gl.issueBoards.BoardsStore.addList({
});
id: 1,
position: 0,
title: 'Test',
list_type: 'backlog'
});
const list = gl.issueBoards.BoardsStore.findList('id', 1, 'backlog');
expect(list).toBeDefined();
it('finds list limited by type', () => {
gl.issueBoards.BoardsStore.addList({
id: 1,
position: 0,
title: 'Test',
list_type: 'backlog'
});
});
const list = gl.issueBoards.BoardsStore.findList('id', 1, 'backlog');
it('gets issue when new list added', (done) => {
expect(list).toBeDefined();
gl.issueBoards.BoardsStore.addList(listObj);
});
const list = gl.issueBoards.BoardsStore.findList('id', 1);
expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(1);
it('gets issue when new list added', (done) => {
gl.issueBoards.BoardsStore.addList(listObj);
const list = gl.issueBoards.BoardsStore.findList('id', 1);
setTimeout(() => {
expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(1);
expect(list.issues.length).toBe(1);
expect(list.issues[0].id).toBe(1);
done();
}, 0);
});
it('persists new list', (done) => {
setTimeout(() => {
gl.issueBoards.BoardsStore.new({
expect(list.issues.length).toBe(1);
title: 'Test',
expect(list.issues[0].id).toBe(1);
type: 'label',
done();
label: {
}, 0);
id: 1,
});
title: 'Testing',
color: 'red',
description: 'testing;'
}
});
expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(1);
setTimeout(() => {
const list = gl.issueBoards.BoardsStore.findList('id', 1);
expect(list).toBeDefined();
expect(list.id).toBe(1);
expect(list.position).toBe(0);
done();
}, 0);
});
it('check for blank state adding', () => {
it('persists new list', (done) => {
expect(gl.issueBoards.BoardsStore.shouldAddBlankState()).toBe(true);
gl.issueBoards.BoardsStore.new({
title: 'Test',
type: 'label',
label: {
id: 1,
title: 'Testing',
color: 'red',
description: 'testing;'
}
});
});
expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(1);
it('check for blank state not adding', () => {
setTimeout(() => {
gl.issueBoards.BoardsStore.addList(listObj);
const list = gl.issueBoards.BoardsStore.findList('id', 1);
expect(gl.issueBoards.BoardsStore.shouldAddBlankState()).toBe(false);
expect(list).toBeDefined();
});
expect(list.id).toBe(1);
expect(list.position).toBe(0);
done();
}, 0);
});
it('check for blank state adding when backlog & done list exist', () => {
it('check for blank state adding', () => {
gl.issueBoards.BoardsStore.addList({
expect(gl.issueBoards.BoardsStore.shouldAddBlankState()).toBe(true);
list_type: 'backlog'
});
});
gl.issueBoards.BoardsStore.addList({
it('check for blank state not adding', () => {
list_type: 'done'
gl.issueBoards.BoardsStore.addList(listObj);
});
expect(gl.issueBoards.BoardsStore.shouldAddBlankState()).toBe(false);
});
expect(gl.issueBoards.BoardsStore.shouldAddBlankState()).toBe(true);
it('check for blank state adding when backlog & done list exist', () => {
gl.issueBoards.BoardsStore.addList({
list_type: 'backlog'
});
});
gl.issueBoards.BoardsStore.addList({
list_type: 'done'
});
expect(gl.issueBoards.BoardsStore.shouldAddBlankState()).toBe(true);
});
it('adds the blank state', () => {
it('adds the blank state', () => {
gl.issueBoards.BoardsStore.addBlankState();
gl.issueBoards.BoardsStore.addBlankState();
const list = gl.issueBoards.BoardsStore.findList('type', 'blank', 'blank');
const list = gl.issueBoards.BoardsStore.findList('type', 'blank', 'blank');
expect(list).toBeDefined();
expect(list).toBeDefined();
});
});
it('removes list from state', () => {
it('removes list from state', () => {
gl.issueBoards.BoardsStore.addList(listObj);
gl.issueBoards.BoardsStore.addList(listObj);
expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(1);
expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(1);
gl.issueBoards.BoardsStore.removeList(1, 'label');
gl.issueBoards.BoardsStore.removeList(1, 'label');
expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(0);
expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(0);
});
});
it('moves the position of lists', () => {
it('moves the position of lists', () => {
const listOne = gl.issueBoards.BoardsStore.addList(listObj),
const listOne = gl.issueBoards.BoardsStore.addList(listObj),
listTwo = gl.issueBoards.BoardsStore.addList(listObjDuplicate);
listTwo = gl.issueBoards.BoardsStore.addList(listObjDuplicate);
expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(2);
expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(2);
gl.issueBoards.BoardsStore.moveList(listOne, ['2', '1']);
gl.issueBoards.BoardsStore.moveList(listOne, ['2', '1']);
expect(listOne.position).toBe(1);
expect(listOne.position).toBe(1);
});
});
it('moves an issue from one list to another', (done) => {
it('moves an issue from one list to another', (done) => {
const listOne = gl.issueBoards.BoardsStore.addList(listObj),
const listOne = gl.issueBoards.BoardsStore.addList(listObj),
listTwo = gl.issueBoards.BoardsStore.addList(listObjDuplicate);
listTwo = gl.issueBoards.BoardsStore.addList(listObjDuplicate);
expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(2);
expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(2);
setTimeout(() => {
setTimeout(() => {
expect(listOne.issues.length).toBe(1);
expect(listOne.issues.length).toBe(1);
expect(listTwo.issues.length).toBe(1);
expect(listTwo.issues.length).toBe(1);
gl.issueBoards.BoardsStore.moveIssueToList(listOne, listTwo, listOne.findIssue(1));
gl.issueBoards.BoardsStore.moveIssueToList(listOne, listTwo, listOne.findIssue(1));
expect(listOne.issues.length).toBe(0);
expect(listOne.issues.length).toBe(0);
expect(listTwo.issues.length).toBe(1);
expect(listTwo.issues.length).toBe(1);
done();
done();
}, 0);
}, 0);
});
});
});
});
});
})
()
;
});
spec/javascripts/boards/list_spec.js.es6
View file @
c16d5bcd
...
@@ -17,12 +17,17 @@ describe('List model', () => {
...
@@ -17,12 +17,17 @@ describe('List model', () => {
let list;
let list;
beforeEach(() => {
beforeEach(() => {
Vue.http.interceptors.push(boardsMockInterceptor);
gl.boardService = new BoardService('/test/issue-boards/board', '1');
gl.boardService = new BoardService('/test/issue-boards/board', '1');
gl.issueBoards.BoardsStore.create();
gl.issueBoards.BoardsStore.create();
list = new List(listObj);
list = new List(listObj);
});
});
afterEach(() => {
Vue.http.interceptors = _.without(Vue.http.interceptors, boardsMockInterceptor);
});
it('gets issues when created', (done) => {
it('gets issues when created', (done) => {
setTimeout(() => {
setTimeout(() => {
expect(list.issues.length).toBe(1);
expect(list.issues.length).toBe(1);
...
...
spec/javascripts/boards/mock_data.js.es6
View file @
c16d5bcd
...
@@ -48,10 +48,10 @@ const BoardsMockData = {
...
@@ -48,10 +48,10 @@ const BoardsMockData = {
}
}
};
};
Vue.http.interceptors.push(
(request, next) => {
const boardsMockInterceptor =
(request, next) => {
const body = BoardsMockData[request.method][request.url];
const body = BoardsMockData[request.method][request.url];
next(request.respondWith(JSON.stringify(body), {
next(request.respondWith(JSON.stringify(body), {
status: 200
status: 200
}));
}));
}
)
;
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment