Commit f57b1323 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Fix failed tests and add extra test

parent 2dd84abf
...@@ -167,9 +167,7 @@ const boardsStore = { ...@@ -167,9 +167,7 @@ const boardsStore = {
return filteredList[0]; return filteredList[0];
}, },
findListByLabelId(id) { findListByLabelId(id) {
return this.state.lists.find(list => { return this.state.lists.find(list => list.type === 'label' && list.label.id === id);
return list.type === 'label' && list.label.id === id;
});
}, },
updateFiltersUrl() { updateFiltersUrl() {
window.history.pushState(null, null, `?${this.filter.path}`); window.history.pushState(null, null, `?${this.filter.path}`);
......
...@@ -170,7 +170,7 @@ export default class LabelsSelect { ...@@ -170,7 +170,7 @@ export default class LabelsSelect {
axios axios
.get(labelUrl) .get(labelUrl)
.then(res => { .then(res => {
let data = res.data; let { data } = res;
if ($dropdown.hasClass('js-extra-options')) { if ($dropdown.hasClass('js-extra-options')) {
var extraData = []; var extraData = [];
if (showNo) { if (showNo) {
...@@ -256,7 +256,8 @@ export default class LabelsSelect { ...@@ -256,7 +256,8 @@ export default class LabelsSelect {
} }
} }
if (label.color) { if (label.color) {
colorEl = "<span class='dropdown-label-box' style='background: " + label.color + "'></span>"; colorEl =
"<span class='dropdown-label-box' style='background: " + label.color + "'></span>";
} else { } else {
colorEl = ''; colorEl = '';
} }
......
...@@ -65,6 +65,13 @@ describe('Store', () => { ...@@ -65,6 +65,13 @@ describe('Store', () => {
expect(list).toBeDefined(); expect(list).toBeDefined();
}); });
it('finds list by label ID', () => {
boardsStore.addList(listObj);
const list = boardsStore.findListByLabelId(listObj.label.id);
expect(list.id).toBe(listObj.id);
});
it('gets issue when new list added', done => { it('gets issue when new list added', done => {
boardsStore.addList(listObj); boardsStore.addList(listObj);
const list = boardsStore.findList('id', listObj.id); const list = boardsStore.findList('id', listObj.id);
......
...@@ -55,15 +55,27 @@ describe('Issue model', () => { ...@@ -55,15 +55,27 @@ describe('Issue model', () => {
expect(issue.labels.length).toBe(2); expect(issue.labels.length).toBe(2);
}); });
it('does not add existing label', () => { it('does not add label if label id exists', () => {
issue.addLabel({
id: 1,
title: 'test 2',
color: 'blue',
description: 'testing',
});
expect(issue.labels.length).toBe(1);
expect(issue.labels[0].color).toBe('red');
});
it('adds other label with same title', () => {
issue.addLabel({ issue.addLabel({
id: 2, id: 2,
title: 'test', title: 'test',
color: 'blue', color: 'blue',
description: 'bugs!', description: 'other test',
}); });
expect(issue.labels.length).toBe(1); expect(issue.labels.length).toBe(2);
}); });
it('finds label', () => { it('finds label', () => {
......
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