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

update some tests

parent 1ae579f8
......@@ -143,6 +143,27 @@ describe('Api', () => {
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', () => {
......
......@@ -52,6 +52,7 @@ describe('Issue card component', () => {
issue,
issueLinkBase: '/test',
rootPath: '/',
groupId: null,
};
},
components: {
......@@ -61,6 +62,7 @@ describe('Issue card component', () => {
<issue-card
:issue="issue"
:list="list"
:group-id="groupId"
:issue-link-base="issueLinkBase"
:root-path="rootPath"></issue-card>
`,
......@@ -239,65 +241,107 @@ describe('Issue card component', () => {
});
describe('labels', () => {
describe('exists', () => {
beforeEach((done) => {
component.issue.addLabel(label1);
beforeEach((done) => {
component.issue.addLabel(label1);
Vue.nextTick(() => done());
});
Vue.nextTick(() => done());
});
it('renders list label', () => {
expect(
component.$el.querySelectorAll('.label').length,
).toBe(2);
it('renders list label', () => {
expect(
component.$el.querySelectorAll('.label').length,
).toBe(2);
});
it('renders label', () => {
const nodes = [];
component.$el.querySelectorAll('.label').forEach((label) => {
nodes.push(label.title);
});
it('renders label', () => {
const nodes = [];
component.$el.querySelectorAll('.label').forEach((label) => {
nodes.push(label.title);
});
expect(
nodes.includes(label1.description),
).toBe(true);
});
expect(
nodes.includes(label1.description),
).toBe(true);
});
it('sets label description as title', () => {
expect(
component.$el.querySelector('.label').getAttribute('title'),
).toContain(label1.description);
});
it('sets label description as title', () => {
expect(
component.$el.querySelector('.label').getAttribute('title'),
).toContain(label1.description);
it('sets background color of button', () => {
const nodes = [];
component.$el.querySelectorAll('.label').forEach((label) => {
nodes.push(label.style.backgroundColor);
});
it('sets background color of button', () => {
const nodes = [];
component.$el.querySelectorAll('.label').forEach((label) => {
nodes.push(label.style.backgroundColor);
});
expect(
nodes.includes(label1.color),
).toBe(true);
});
expect(
nodes.includes(label1.color),
).toBe(true);
});
it('does not render label if label does not have an ID', (done) => {
component.issue.addLabel(new ListLabel({
title: 'closed',
}));
it('does not render label if label does not have an ID', (done) => {
component.issue.addLabel(new ListLabel({
title: 'closed',
}));
Vue.nextTick()
.then(() => {
expect(
component.$el.querySelectorAll('.label').length,
).toBe(2);
expect(
component.$el.textContent,
).not.toContain('Closed');
Vue.nextTick()
.then(() => {
expect(
component.$el.querySelectorAll('.label').length,
).toBe(2);
expect(
component.$el.textContent,
).not.toContain('closed');
done();
})
.catch(done.fail);
});
done();
})
.catch(done.fail);
});
it('shows group labels on group boards', (done) => {
component.issue.addLabel(new ListLabel({
id: _.random(10000),
title: 'Group label',
type: 'GroupLabel',
}));
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