Commit 8cce7368 authored by Phil Hughes's avatar Phil Hughes

Merge branch 'add-specs-multiple-assignees-issue-board' into 'multiple_assignees_review'

Add specs for multiple assignees issue board cards

See merge request !1736
parents 99dc45e0 abb73256
...@@ -40,6 +40,7 @@ describe('Issue card component', () => { ...@@ -40,6 +40,7 @@ describe('Issue card component', () => {
iid: 1, iid: 1,
confidential: false, confidential: false,
labels: [list.label], labels: [list.label],
assignees: [],
}); });
component = new Vue({ component = new Vue({
...@@ -92,12 +93,12 @@ describe('Issue card component', () => { ...@@ -92,12 +93,12 @@ describe('Issue card component', () => {
it('renders confidential icon', (done) => { it('renders confidential icon', (done) => {
component.issue.confidential = true; component.issue.confidential = true;
setTimeout(() => { Vue.nextTick(() => {
expect( expect(
component.$el.querySelector('.confidential-icon'), component.$el.querySelector('.confidential-icon'),
).not.toBeNull(); ).not.toBeNull();
done(); done();
}, 0); });
}); });
it('renders issue ID with #', () => { it('renders issue ID with #', () => {
...@@ -109,34 +110,32 @@ describe('Issue card component', () => { ...@@ -109,34 +110,32 @@ describe('Issue card component', () => {
describe('assignee', () => { describe('assignee', () => {
it('does not render assignee', () => { it('does not render assignee', () => {
expect( expect(
component.$el.querySelector('.card-assignee'), component.$el.querySelector('.card-assignee .avatar'),
).toBeNull(); ).toBeNull();
}); });
describe('exists', () => { describe('exists', () => {
beforeEach((done) => { beforeEach((done) => {
component.issue.assignee = user; component.issue.assignees = [user];
setTimeout(() => { Vue.nextTick(() => done());
done();
}, 0);
}); });
it('renders assignee', () => { it('renders assignee', () => {
expect( expect(
component.$el.querySelector('.card-assignee'), component.$el.querySelector('.card-assignee .avatar'),
).not.toBeNull(); ).not.toBeNull();
}); });
it('sets title', () => { it('sets title', () => {
expect( expect(
component.$el.querySelector('.card-assignee').getAttribute('title'), component.$el.querySelector('.card-assignee a').getAttribute('title'),
).toContain(`Assigned to ${user.name}`); ).toContain(`Assigned to ${user.name}`);
}); });
it('sets users path', () => { it('sets users path', () => {
expect( expect(
component.$el.querySelector('.card-assignee').getAttribute('href'), component.$el.querySelector('.card-assignee a').getAttribute('href'),
).toBe('/test'); ).toBe('/test');
}); });
...@@ -148,6 +147,76 @@ describe('Issue card component', () => { ...@@ -148,6 +147,76 @@ describe('Issue card component', () => {
}); });
}); });
describe('multiple assignees', () => {
beforeEach((done) => {
component.issue.assignees = [
user,
new ListUser({
id: 2,
name: 'user2',
username: 'user2',
avatar: 'test_image',
}),
new ListUser({
id: 3,
name: 'user3',
username: 'user3',
avatar: 'test_image',
}),
new ListUser({
id: 4,
name: 'user4',
username: 'user4',
avatar: 'test_image',
})];
Vue.nextTick(() => done());
});
it('renders all four assignees', () => {
expect(component.$el.querySelectorAll('.card-assignee .avatar').length).toEqual(4);
});
describe('more than four assignees', () => {
beforeEach((done) => {
component.issue.assignees.push(new ListUser({
id: 5,
name: 'user5',
username: 'user5',
avatar: 'test_image',
}));
Vue.nextTick(() => done());
});
it('renders more avatar counter', () => {
expect(component.$el.querySelector('.card-assignee .avatar-counter').innerText).toEqual('+2');
});
it('renders three assignees', () => {
expect(component.$el.querySelectorAll('.card-assignee .avatar').length).toEqual(3);
});
it('renders 99+ avatar counter', (done) => {
for(let i = 5; i < 104; i++) {
const u = new ListUser({
id: i,
name: 'name',
username: 'username',
avatar: 'test_image',
});
component.issue.assignees.push(u);
}
Vue.nextTick(() => {
expect(component.$el.querySelector('.card-assignee .avatar-counter').innerText).toEqual('99+');
done();
});
});
});
})
describe('labels', () => { describe('labels', () => {
it('does not render any', () => { it('does not render any', () => {
expect( expect(
...@@ -159,9 +228,7 @@ describe('Issue card component', () => { ...@@ -159,9 +228,7 @@ describe('Issue card component', () => {
beforeEach((done) => { beforeEach((done) => {
component.issue.addLabel(label1); component.issue.addLabel(label1);
setTimeout(() => { Vue.nextTick(() => done());
done();
}, 0);
}); });
it('does not render list label', () => { it('does not render list label', () => {
......
...@@ -27,7 +27,8 @@ describe('Issue model', () => { ...@@ -27,7 +27,8 @@ describe('Issue model', () => {
title: 'test', title: 'test',
color: 'red', color: 'red',
description: 'testing' description: 'testing'
}] }],
assignees: [],
}); });
}); });
...@@ -90,7 +91,8 @@ describe('Issue model', () => { ...@@ -90,7 +91,8 @@ describe('Issue model', () => {
iid: 1, iid: 1,
confidential: false, confidential: false,
relative_position: 1, relative_position: 1,
labels: [] labels: [],
assignees: [],
}); });
expect(relativePositionIssue.position).toBe(1); expect(relativePositionIssue.position).toBe(1);
......
...@@ -94,7 +94,8 @@ describe('List model', () => { ...@@ -94,7 +94,8 @@ describe('List model', () => {
title: 'Testing', title: 'Testing',
iid: 1, iid: 1,
confidential: false, confidential: false,
labels: [list.label, listDup.label] labels: [list.label, listDup.label],
assignees: [],
}); });
list.issues.push(issue); list.issues.push(issue);
......
...@@ -21,12 +21,14 @@ describe('Modal store', () => { ...@@ -21,12 +21,14 @@ describe('Modal store', () => {
iid: 1, iid: 1,
confidential: false, confidential: false,
labels: [], labels: [],
assignees: [],
}); });
issue2 = new ListIssue({ issue2 = new ListIssue({
title: 'Testing', title: 'Testing',
iid: 2, iid: 2,
confidential: false, confidential: false,
labels: [], labels: [],
assignees: [],
}); });
Store.store.issues.push(issue); Store.store.issues.push(issue);
Store.store.issues.push(issue2); Store.store.issues.push(issue2);
......
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