Commit f1d48c25 authored by Clement Ho's avatar Clement Ho

Fix failing spec and eslint

parent 48e49919
...@@ -4,7 +4,7 @@ export default { ...@@ -4,7 +4,7 @@ export default {
for (let i = 0; i < numberUsers; i = i += 1) { for (let i = 0; i < numberUsers; i = i += 1) {
users.push( users.push(
{ {
avatarUrl: 'http://gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', avatar: 'http://gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon',
id: (i + 1), id: (i + 1),
name: `GitLab User ${i}`, name: `GitLab User ${i}`,
username: `gitlab${i}`, username: `gitlab${i}`,
......
import Vue from 'vue'; import Vue from 'vue';
import Assignee from '~/sidebar/components/assignees/assignees'; import Assignee from '~/sidebar/components/assignees/assignees';
import UsersMock from './mock_data'; import UsersMock from './mock_data';
import UsersMockHelper from '../test_helpers/user_mock_data'; import UsersMockHelper from '../helpers/user_mock_data_helper';
describe('Assignee component', () => { describe('Assignee component', () => {
let component; let component;
...@@ -86,7 +86,7 @@ describe('Assignee component', () => { ...@@ -86,7 +86,7 @@ describe('Assignee component', () => {
const collapsed = component.$el.querySelector('.sidebar-collapsed-icon'); const collapsed = component.$el.querySelector('.sidebar-collapsed-icon');
const assignee = collapsed.children[0]; const assignee = collapsed.children[0];
expect(collapsed.childElementCount).toEqual(1); expect(collapsed.childElementCount).toEqual(1);
expect(assignee.querySelector('.avatar').getAttribute('src')).toEqual(UsersMock.user.avatarUrl); expect(assignee.querySelector('.avatar').getAttribute('src')).toEqual(UsersMock.user.avatar);
expect(assignee.querySelector('.avatar').getAttribute('alt')).toEqual(`${UsersMock.user.name}'s avatar`); expect(assignee.querySelector('.avatar').getAttribute('alt')).toEqual(`${UsersMock.user.name}'s avatar`);
expect(assignee.querySelector('.author').innerText.trim()).toEqual(UsersMock.user.name); expect(assignee.querySelector('.author').innerText.trim()).toEqual(UsersMock.user.name);
}); });
...@@ -104,7 +104,7 @@ describe('Assignee component', () => { ...@@ -104,7 +104,7 @@ describe('Assignee component', () => {
expect(component.$el.querySelector('.author_link')).not.toBeNull(); expect(component.$el.querySelector('.author_link')).not.toBeNull();
// The image // The image
expect(component.$el.querySelector('.author_link img').getAttribute('src')).toEqual(UsersMock.user.avatarUrl); expect(component.$el.querySelector('.author_link img').getAttribute('src')).toEqual(UsersMock.user.avatar);
// Author name // Author name
expect(component.$el.querySelector('.author_link .author').innerText.trim()).toEqual(UsersMock.user.name); expect(component.$el.querySelector('.author_link .author').innerText.trim()).toEqual(UsersMock.user.name);
// Username // Username
...@@ -141,12 +141,12 @@ describe('Assignee component', () => { ...@@ -141,12 +141,12 @@ describe('Assignee component', () => {
expect(collapsed.childElementCount).toEqual(2); expect(collapsed.childElementCount).toEqual(2);
const first = collapsed.children[0]; const first = collapsed.children[0];
expect(first.querySelector('.avatar').getAttribute('src')).toEqual(users[0].avatarUrl); expect(first.querySelector('.avatar').getAttribute('src')).toEqual(users[0].avatar);
expect(first.querySelector('.avatar').getAttribute('alt')).toEqual(`${users[0].name}'s avatar`); expect(first.querySelector('.avatar').getAttribute('alt')).toEqual(`${users[0].name}'s avatar`);
expect(first.querySelector('.author').innerText.trim()).toEqual(users[0].name); expect(first.querySelector('.author').innerText.trim()).toEqual(users[0].name);
const second = collapsed.children[1]; const second = collapsed.children[1];
expect(second.querySelector('.avatar').getAttribute('src')).toEqual(users[1].avatarUrl); expect(second.querySelector('.avatar').getAttribute('src')).toEqual(users[1].avatar);
expect(second.querySelector('.avatar').getAttribute('alt')).toEqual(`${users[1].name}'s avatar`); expect(second.querySelector('.avatar').getAttribute('alt')).toEqual(`${users[1].name}'s avatar`);
expect(second.querySelector('.author').innerText.trim()).toEqual(users[1].name); expect(second.querySelector('.author').innerText.trim()).toEqual(users[1].name);
}); });
...@@ -165,7 +165,7 @@ describe('Assignee component', () => { ...@@ -165,7 +165,7 @@ describe('Assignee component', () => {
expect(collapsed.childElementCount).toEqual(2); expect(collapsed.childElementCount).toEqual(2);
const first = collapsed.children[0]; const first = collapsed.children[0];
expect(first.querySelector('.avatar').getAttribute('src')).toEqual(users[0].avatarUrl); expect(first.querySelector('.avatar').getAttribute('src')).toEqual(users[0].avatar);
expect(first.querySelector('.avatar').getAttribute('alt')).toEqual(`${users[0].name}'s avatar`); expect(first.querySelector('.avatar').getAttribute('alt')).toEqual(`${users[0].name}'s avatar`);
expect(first.querySelector('.author').innerText.trim()).toEqual(users[0].name); expect(first.querySelector('.author').innerText.trim()).toEqual(users[0].name);
......
...@@ -93,7 +93,7 @@ export default { ...@@ -93,7 +93,7 @@ export default {
human_total_time_spent: null, human_total_time_spent: null,
}, },
user: { user: {
avatarUrl: 'http://gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', avatar: 'http://gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon',
id: 1, id: 1,
name: 'Administrator', name: 'Administrator',
username: 'root', username: 'root',
......
...@@ -24,10 +24,12 @@ describe('Sidebar mediator', () => { ...@@ -24,10 +24,12 @@ describe('Sidebar mediator', () => {
}); });
it('saves assignees', (done) => { it('saves assignees', (done) => {
this.mediator.saveAssignees('issue[assignee_ids]').then((resp) => { this.mediator.saveAssignees('issue[assignee_ids]')
.then((resp) => {
expect(resp.status).toEqual(200); expect(resp.status).toEqual(200);
done(); done();
}); })
.catch(() => {});
}); });
it('fetches the data', () => { it('fetches the data', () => {
......
...@@ -13,16 +13,20 @@ describe('Sidebar service', () => { ...@@ -13,16 +13,20 @@ describe('Sidebar service', () => {
}); });
it('gets the data', (done) => { it('gets the data', (done) => {
this.service.get().then((resp) => { this.service.get()
.then((resp) => {
expect(resp).toBeDefined(); expect(resp).toBeDefined();
done(); done();
}); })
.catch(() => {});
}); });
it('updates the data', (done) => { it('updates the data', (done) => {
this.service.update('issue[assignee_ids]', [1]).then((resp) => { this.service.update('issue[assignee_ids]', [1])
.then((resp) => {
expect(resp).toBeDefined(); expect(resp).toBeDefined();
done(); done();
}); })
.catch(() => {});
}); });
}); });
import SidebarStore from '~/sidebar/stores/sidebar_store'; import SidebarStore from '~/sidebar/stores/sidebar_store';
import Mock from './mock_data'; import Mock from './mock_data';
import UsersMockHelper from '../test_helpers/user_mock_data'; import UsersMockHelper from '../helpers/user_mock_data_helper';
describe('Sidebar store', () => { describe('Sidebar store', () => {
const assignee = { const assignee = {
......
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