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 = {
return filteredList[0];
},
findListByLabelId(id) {
return this.state.lists.find(list => {
return list.type === 'label' && list.label.id === id;
});
return this.state.lists.find(list => list.type === 'label' && list.label.id === id);
},
updateFiltersUrl() {
window.history.pushState(null, null, `?${this.filter.path}`);
......
......@@ -170,7 +170,7 @@ export default class LabelsSelect {
axios
.get(labelUrl)
.then(res => {
let data = res.data;
let { data } = res;
if ($dropdown.hasClass('js-extra-options')) {
var extraData = [];
if (showNo) {
......@@ -256,7 +256,8 @@ export default class LabelsSelect {
}
}
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 {
colorEl = '';
}
......
......@@ -65,6 +65,13 @@ describe('Store', () => {
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 => {
boardsStore.addList(listObj);
const list = boardsStore.findList('id', listObj.id);
......
......@@ -55,15 +55,27 @@ describe('Issue model', () => {
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({
id: 2,
title: 'test',
color: 'blue',
description: 'bugs!',
description: 'other test',
});
expect(issue.labels.length).toBe(1);
expect(issue.labels.length).toBe(2);
});
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