Commit 18fa27d9 authored by Phil Hughes's avatar Phil Hughes

Merge branch 'winh-issue_card_spec-ee' into 'master'

Remove EE-specic parts from issue_card_spec.js

Closes #10503

See merge request gitlab-org/gitlab-ee!10620
parents bd230fb2 dc00a280
/* global ListLabel */
/* global ListIssue */
import Vue from 'vue'; import Vue from 'vue';
import _ from 'underscore';
import '~/vue_shared/models/label';
import '~/vue_shared/models/assignee';
import '~/boards/models/issue'; import '~/boards/models/issue';
import '~/boards/models/list';
import IssueCardInner from '~/boards/components/issue_card_inner.vue'; import IssueCardInner from '~/boards/components/issue_card_inner.vue';
import ListIssue from 'ee/boards/models/issue';
import mountComponent from 'spec/helpers/vue_mount_component_helper';
import { listObj } from 'spec/boards/mock_data'; import { listObj } from 'spec/boards/mock_data';
describe('Issue card component', () => { describe('Issue card component', () => {
let vm; const label1 = new ListLabel({
const Component = Vue.extend(IssueCardInner); id: 3,
const list = listObj; title: 'testing 123',
const issue = new ListIssue({ color: 'blue',
title: 'Testing', text_color: 'white',
id: 1, description: 'test',
iid: 1,
confidential: false,
labels: [list.label],
assignees: [],
}); });
let component;
let issue;
let list;
afterEach(() => { beforeEach(() => {
vm.$destroy(); setFixtures('<div class="test-container"></div>');
});
it('does not render issue weight if none specified', () => { list = listObj;
vm = mountComponent(Component, { issue = new ListIssue({
list, title: 'Testing',
issue, id: 1,
issueLinkBase: '/test', iid: 1,
rootPath: '/', confidential: false,
groupId: null, labels: [list.label],
assignees: [],
reference_path: '#1',
real_path: '/test/1',
}); });
expect(vm.$el.querySelector('.board-card-weight')).toBeNull(); component = new Vue({
el: document.querySelector('.test-container'),
components: {
'issue-card': IssueCardInner,
},
data() {
return {
list,
issue,
issueLinkBase: '/test',
rootPath: '/',
groupId: null,
};
},
template: `
<issue-card
:issue="issue"
:list="list"
:group-id="groupId"
:issue-link-base="issueLinkBase"
:root-path="rootPath"></issue-card>
`,
});
}); });
it('renders issue weight if specified', () => { describe('labels', () => {
vm = mountComponent(Component, { beforeEach(done => {
list, component.issue.addLabel(label1);
issue: {
...issue, Vue.nextTick(() => done());
weight: 2,
},
issueLinkBase: '/test',
rootPath: '/',
groupId: null,
}); });
const el = vm.$el.querySelector('.board-card-weight');
expect(el).not.toBeNull(); it('shows group labels on group boards', done => {
expect(el.textContent.trim()).toContain('2'); component.issue.addLabel(
new ListLabel({
id: _.random(10000),
title: 'Group label',
type: 'GroupLabel',
}),
);
component.groupId = 1;
Vue.nextTick()
.then(() => {
expect(component.$el.querySelectorAll('.badge').length).toBe(3);
expect(component.$el.textContent).toContain('Group label');
done();
})
.catch(done.fail);
});
it('shows 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('.badge').length).toBe(3);
expect(component.$el.textContent).toContain('Project label');
done();
})
.catch(done.fail);
});
}); });
}); });
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
/* global ListIssue */ /* global ListIssue */
import Vue from 'vue'; import Vue from 'vue';
import _ from 'underscore';
import '~/vue_shared/models/label'; import '~/vue_shared/models/label';
import '~/vue_shared/models/assignee'; import '~/vue_shared/models/assignee';
...@@ -56,14 +55,12 @@ describe('Issue card component', () => { ...@@ -56,14 +55,12 @@ describe('Issue card component', () => {
issue, issue,
issueLinkBase: '/test', issueLinkBase: '/test',
rootPath: '/', rootPath: '/',
groupId: null,
}; };
}, },
template: ` template: `
<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>
`, `,
...@@ -287,47 +284,5 @@ describe('Issue card component', () => { ...@@ -287,47 +284,5 @@ describe('Issue card component', () => {
}) })
.catch(done.fail); .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('.badge').length).toBe(3);
expect(component.$el.textContent).toContain('Group label');
done();
})
.catch(done.fail);
});
it('shows 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('.badge').length).toBe(3);
expect(component.$el.textContent).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