Commit 8da4fff9 authored by Simon Knox's avatar Simon Knox

update some tests

parent 1ae579f8
...@@ -143,6 +143,27 @@ describe('Api', () => { ...@@ -143,6 +143,27 @@ describe('Api', () => {
done(); done();
}); });
}); });
it('creates a new group label', (done) => {
const namespace = 'some namespace';
const labelData = { some: 'data' };
const expectedUrl = `${dummyUrlRoot}/groups/${namespace}/labels`;
const expectedData = {
label: labelData,
};
spyOn(jQuery, 'ajax').and.callFake((request) => {
expect(request.url).toEqual(expectedUrl);
expect(request.dataType).toEqual('json');
expect(request.type).toEqual('POST');
expect(request.data).toEqual(expectedData);
return sendDummyResponse();
});
Api.newLabel(namespace, null, labelData, (response) => {
expect(response).toBe(dummyResponse);
done();
});
});
}); });
describe('groupProjects', () => { describe('groupProjects', () => {
......
...@@ -52,6 +52,7 @@ describe('Issue card component', () => { ...@@ -52,6 +52,7 @@ describe('Issue card component', () => {
issue, issue,
issueLinkBase: '/test', issueLinkBase: '/test',
rootPath: '/', rootPath: '/',
groupId: null,
}; };
}, },
components: { components: {
...@@ -61,6 +62,7 @@ describe('Issue card component', () => { ...@@ -61,6 +62,7 @@ describe('Issue card component', () => {
<issue-card <issue-card
:issue="issue" :issue="issue"
:list="list" :list="list"
:group-id="groupId"
:issue-link-base="issueLinkBase" :issue-link-base="issueLinkBase"
:root-path="rootPath"></issue-card> :root-path="rootPath"></issue-card>
`, `,
...@@ -239,65 +241,107 @@ describe('Issue card component', () => { ...@@ -239,65 +241,107 @@ describe('Issue card component', () => {
}); });
describe('labels', () => { describe('labels', () => {
describe('exists', () => { beforeEach((done) => {
beforeEach((done) => { component.issue.addLabel(label1);
component.issue.addLabel(label1);
Vue.nextTick(() => done()); Vue.nextTick(() => done());
}); });
it('renders list label', () => { it('renders list label', () => {
expect( expect(
component.$el.querySelectorAll('.label').length, component.$el.querySelectorAll('.label').length,
).toBe(2); ).toBe(2);
});
it('renders label', () => {
const nodes = [];
component.$el.querySelectorAll('.label').forEach((label) => {
nodes.push(label.title);
}); });
it('renders label', () => { expect(
const nodes = []; nodes.includes(label1.description),
component.$el.querySelectorAll('.label').forEach((label) => { ).toBe(true);
nodes.push(label.title); });
});
expect( it('sets label description as title', () => {
nodes.includes(label1.description), expect(
).toBe(true); component.$el.querySelector('.label').getAttribute('title'),
}); ).toContain(label1.description);
});
it('sets label description as title', () => { it('sets background color of button', () => {
expect( const nodes = [];
component.$el.querySelector('.label').getAttribute('title'), component.$el.querySelectorAll('.label').forEach((label) => {
).toContain(label1.description); nodes.push(label.style.backgroundColor);
}); });
it('sets background color of button', () => { expect(
const nodes = []; nodes.includes(label1.color),
component.$el.querySelectorAll('.label').forEach((label) => { ).toBe(true);
nodes.push(label.style.backgroundColor); });
});
expect( it('does not render label if label does not have an ID', (done) => {
nodes.includes(label1.color), component.issue.addLabel(new ListLabel({
).toBe(true); title: 'closed',
}); }));
it('does not render label if label does not have an ID', (done) => { Vue.nextTick()
component.issue.addLabel(new ListLabel({ .then(() => {
title: 'closed', expect(
})); component.$el.querySelectorAll('.label').length,
).toBe(2);
expect(
component.$el.textContent,
).not.toContain('Closed');
Vue.nextTick() done();
.then(() => { })
expect( .catch(done.fail);
component.$el.querySelectorAll('.label').length, });
).toBe(2);
expect( it('shows group labels on group boards', (done) => {
component.$el.textContent, component.issue.addLabel(new ListLabel({
).not.toContain('closed'); id: _.random(10000),
title: 'Group label',
done(); type: 'GroupLabel',
}) }));
.catch(done.fail); component.groupId = 1;
});
Vue.nextTick()
.then(() => {
expect(
component.$el.querySelectorAll('.label').length,
).toBe(3);
expect(
component.$el.textContent,
).toContain('Group label');
done();
})
.catch(done.fail);
});
it('does not show project labels on group boards', (done) => {
component.issue.addLabel(new ListLabel({
id: 123,
title: 'Project label',
type: 'ProjectLabel',
}));
component.groupId = 1;
Vue.nextTick()
.then(() => {
expect(
component.$el.querySelectorAll('.label').length,
).toBe(2);
expect(
component.$el.textContent,
).not.toContain('Project label');
done();
})
.catch(done.fail);
}); });
}); });
}); });
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