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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
954b0dae
Commit
954b0dae
authored
Aug 10, 2016
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added JS spec tests for store & models
parent
9a579e82
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
382 additions
and
1 deletion
+382
-1
app/assets/javascripts/boards/stores/boards_store.js.es6
app/assets/javascripts/boards/stores/boards_store.js.es6
+2
-1
spec/javascripts/boards/boards_store_spec.js.es6
spec/javascripts/boards/boards_store_spec.js.es6
+155
-0
spec/javascripts/boards/issue_spec.js.es6
spec/javascripts/boards/issue_spec.js.es6
+83
-0
spec/javascripts/boards/list_spec.js.es6
spec/javascripts/boards/list_spec.js.es6
+89
-0
spec/javascripts/boards/mock_data.js.es6
spec/javascripts/boards/mock_data.js.es6
+53
-0
No files found.
app/assets/javascripts/boards/stores/boards_store.js.es6
View file @
954b0dae
...
...
@@ -31,9 +31,10 @@
this.removeBlankState();
},
updateNewListDropdown: function () {
const data = $('.js-new-board-list').data('glDropdown').renderedData
;
let data = $('.js-new-board-list').data('glDropdown')
;
if (data) {
data = data.renderedData;
$('.js-new-board-list').data('glDropdown').renderData(data);
}
},
...
...
spec/javascripts/boards/boards_store_spec.js.es6
0 → 100644
View file @
954b0dae
//= 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');
BoardsStore.create();
$.cookie('issue_board_welcome_hidden', 'false');
});
describe('Store', () => {
it('starts with a blank state', () => {
expect(BoardsStore.state.lists.length).toBe(0);
});
describe('lists', () => {
it('creates new list without persisting to DB', () => {
BoardsStore.addList(listObj);
expect(BoardsStore.state.lists.length).toBe(1);
});
it('finds list by ID', () => {
BoardsStore.addList(listObj);
const list = BoardsStore.findList('id', 1);
expect(list.id).toBe(1);
});
it('finds list by type', () => {
BoardsStore.addList(listObj);
const list = BoardsStore.findList('type', 'label');
expect(list).toBeDefined();
});
it('gets issue when new list added', (done) => {
BoardsStore.addList(listObj);
const list = BoardsStore.findList('id', 1);
expect(BoardsStore.state.lists.length).toBe(1);
setTimeout(() => {
expect(list.issues.length).toBe(1);
done();
}, 0);
});
it('persists new list', (done) => {
BoardsStore.new({
title: 'Test',
type: 'label',
label: {
id: 1,
title: 'Testing',
color: 'red',
description: 'testing;'
}
});
expect(BoardsStore.state.lists.length).toBe(1);
setTimeout(() => {
const list = 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', () => {
expect(BoardsStore.shouldAddBlankState()).toBe(true);
});
it('check for blank state not adding', () => {
BoardsStore.addList(listObj);
expect(BoardsStore.shouldAddBlankState()).toBe(false);
});
it('check for blank state adding when backlog & done list exist', () => {
BoardsStore.addList({
list_type: 'backlog'
});
BoardsStore.addList({
list_type: 'done'
});
expect(BoardsStore.shouldAddBlankState()).toBe(true);
});
it('adds the blank state', () => {
BoardsStore.addBlankState();
const list = BoardsStore.findList('type', 'blank');
expect(list).toBeDefined();
});
it('removes list from state', () => {
BoardsStore.addList(listObj);
expect(BoardsStore.state.lists.length).toBe(1);
BoardsStore.removeList(1);
expect(BoardsStore.state.lists.length).toBe(0);
});
it('moves the position of lists', () => {
BoardsStore.addList(listObj);
BoardsStore.addList(listObjDuplicate);
expect(BoardsStore.state.lists.length).toBe(2);
BoardsStore.moveList(0, 1);
const list = BoardsStore.findList('id', 1);
expect(list.position).toBe(1);
});
it('moves an issue from one list to another', (done) => {
BoardsStore.addList(listObj);
BoardsStore.addList(listObjDuplicate);
expect(BoardsStore.state.lists.length).toBe(2);
setTimeout(() => {
const list = BoardsStore.findList('id', 1);
const listTwo = BoardsStore.findList('id', 2);
expect(list.issues.length).toBe(1);
expect(listTwo.issues.length).toBe(1);
BoardsStore.moveCardToList(1, 2, 1);
expect(list.issues.length).toBe(0);
expect(listTwo.issues.length).toBe(1);
done();
});
});
});
});
})();
spec/javascripts/boards/issue_spec.js.es6
0 → 100644
View file @
954b0dae
//= 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
describe('Issue model', () => {
let issue;
beforeEach(() => {
gl.boardService = new BoardService('/test/issue-boards/board');
BoardsStore.create();
issue = new Issue({
title: 'Testing',
iid: 1,
confidential: false,
labels: [{
id: 1,
title: 'test',
color: 'red',
description: 'testing'
}]
});
});
it('has label', () => {
expect(issue.labels.length).toBe(1);
});
it('add new label', () => {
issue.addLabel({
id: 2,
title: 'bug',
color: 'blue',
description: 'bugs!'
});
expect(issue.labels.length).toBe(2);
});
it('does not add existing label', () => {
issue.addLabel({
id: 2,
title: 'test',
color: 'blue',
description: 'bugs!'
});
expect(issue.labels.length).toBe(1);
});
it('finds label', () => {
const label = issue.findLabel(issue.labels[0]);
expect(label).toBeDefined();
});
it('removes label', () => {
const label = issue.findLabel(issue.labels[0]);
issue.removeLabel(label);
expect(issue.labels.length).toBe(0);
});
it('removes multiple labels', () => {
issue.addLabel({
id: 2,
title: 'bug',
color: 'blue',
description: 'bugs!'
});
expect(issue.labels.length).toBe(2);
issue.removeLabels([issue.labels[0], issue.labels[1]]);
expect(issue.labels.length).toBe(0);
});
});
spec/javascripts/boards/list_spec.js.es6
0 → 100644
View file @
954b0dae
//= 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
describe('List model', () => {
let list;
beforeEach(() => {
gl.boardService = new BoardService('/test/issue-boards/board');
BoardsStore.create();
list = new List(listObj);
});
it('gets issues when created', (done) => {
setTimeout(() => {
expect(list.issues.length).toBe(1);
done();
}, 0);
});
it('saves list and returns ID', (done) => {
list = new List({
title: 'test',
label: {
id: 1,
title: 'test',
color: 'red'
}
});
list.save();
setTimeout(() => {
expect(list.id).toBe(1);
expect(list.type).toBe('label');
expect(list.position).toBe(0);
done();
}, 0);
});
it('destroys the list', (done) => {
BoardsStore.addList(listObj);
list = BoardsStore.findList('id', 1);
expect(BoardsStore.state.lists.length).toBe(1);
list.destroy();
setTimeout(() => {
expect(BoardsStore.state.lists.length).toBe(0);
done();
}, 0);
});
it('can\'t search when not backlog', () => {
expect(list.canSearch()).toBe(false);
});
it('can search when backlog', () => {
list.type = 'backlog';
expect(list.canSearch()).toBe(true);
});
it('gets issue from list', (done) => {
setTimeout(() => {
const issue = list.findIssue(1);
expect(issue).toBeDefined();
done();
}, 0);
});
it('removes issue', (done) => {
setTimeout(() => {
const issue = list.findIssue(1);
expect(list.issues.length).toBe(1);
list.removeIssue(issue);
expect(list.issues.length).toBe(0);
done();
}, 0);
});
});
spec/javascripts/boards/mock_data.js.es6
0 → 100644
View file @
954b0dae
const listObj = {
id: 1,
position: 0,
title: 'Test',
list_type: 'label',
label: {
id: 1,
title: 'Testing',
color: 'red',
description: 'testing;'
}
};
const listObjDuplicate = {
id: 2,
position: 1,
title: 'Test',
list_type: 'label',
label: {
id: 2,
title: 'Testing',
color: 'red',
description: 'testing;'
}
};
const BoardsMockData = {
'GET': {
'/test/issue-boards/board/lists{/id}/issues.json': [{
title: 'Testing',
iid: 1,
confidential: false,
labels: []
}]
},
'POST': {
'/test/issue-boards/board/lists{/id}.json': listObj
},
'PUT': {
'/test/issue-boards/board/lists{/id}.json': {}
},
'DELETE': {
'/test/issue-boards/board/lists{/id}.json': {}
}
};
Vue.http.interceptors.push((request, next) => {
const body = BoardsMockData[request.method][request.url];
next(request.respondWith(JSON.stringify(body), {
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