Commit a483433d authored by Rajat Jain's avatar Rajat Jain

Move EE specific testcase to EE spec file

Refactor `board_list` such that we can reuse the parts of component
creation with prop passing with ee specific spec.
parent 508a83e2
import createComponent from 'spec/boards/board_list_common_spec';
describe('BoardList Component', () => {
let mock;
let component;
beforeEach(done => {
const listIssueProps = {
project: {
path: '/test',
},
};
const componentProps = {
groupId: undefined,
issueLinkBase: '/test/:project_path/issues',
};
({ mock, component } = createComponent({
done,
componentProps,
listIssueProps,
}));
});
afterEach(() => {
mock.restore();
});
it('renders link properly in issue', () => {
expect(
component.$el.querySelector('.board-card .board-card-title a').getAttribute('href'),
).not.toContain(':project_path');
});
});
/* global List */
/* global ListIssue */
import MockAdapter from 'axios-mock-adapter';
import Vue from 'vue';
import axios from '~/lib/utils/axios_utils';
import Sortable from 'sortablejs';
import BoardList from '~/boards/components/board_list.vue';
import '~/boards/models/issue';
import '~/boards/models/list';
import { listObj, boardsMockInterceptor, mockBoardService } from './mock_data';
import boardsStore from '~/boards/stores/boards_store';
window.Sortable = Sortable;
export default function createComponent({ done, listIssueProps = {}, componentProps = {} }) {
const el = document.createElement('div');
document.body.appendChild(el);
const mock = new MockAdapter(axios);
mock.onAny().reply(boardsMockInterceptor);
gl.boardService = mockBoardService();
boardsStore.create();
const BoardListComp = Vue.extend(BoardList);
const list = new List(listObj);
const issue = new ListIssue({
title: 'Testing',
id: 1,
iid: 1,
confidential: false,
labels: [],
assignees: [],
...listIssueProps,
});
list.issuesSize = 1;
list.issues.push(issue);
const component = new BoardListComp({
el,
propsData: {
disabled: false,
list,
issues: list.issues,
loading: false,
issueLinkBase: '/issues',
rootPath: '/',
...componentProps,
},
}).$mount();
Vue.nextTick(() => {
done();
});
return { component, mock };
}
/* global List */
/* global ListIssue */
import Vue from 'vue'; import Vue from 'vue';
import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils';
import Sortable from 'sortablejs';
import BoardList from '~/boards/components/board_list.vue';
import eventHub from '~/boards/eventhub'; import eventHub from '~/boards/eventhub';
import '~/boards/models/issue'; import createComponent from './board_list_common_spec';
import '~/boards/models/list';
import boardsStore from '~/boards/stores/boards_store';
import { listObj, boardsMockInterceptor, mockBoardService } from './mock_data';
window.Sortable = Sortable;
describe('Board list component', () => { describe('Board list component', () => {
let mock; let mock;
let component; let component;
beforeEach(done => { beforeEach(done => {
const el = document.createElement('div'); ({ mock, component } = createComponent({ done }));
document.body.appendChild(el);
mock = new MockAdapter(axios);
mock.onAny().reply(boardsMockInterceptor);
gl.boardService = mockBoardService();
boardsStore.create();
const BoardListComp = Vue.extend(BoardList);
const list = new List(listObj);
const issue = new ListIssue({
title: 'Testing',
id: 1,
iid: 1,
confidential: false,
labels: [],
assignees: [],
project: {
path: '/test',
},
});
list.issuesSize = 1;
list.issues.push(issue);
component = new BoardListComp({
el,
propsData: {
disabled: false,
list,
issues: list.issues,
loading: false,
groupId: 1,
issueLinkBase: '/test/:project_path/issues',
rootPath: '/',
},
}).$mount();
Vue.nextTick(() => {
done();
});
}); });
afterEach(() => { afterEach(() => {
...@@ -83,12 +32,6 @@ describe('Board list component', () => { ...@@ -83,12 +32,6 @@ describe('Board list component', () => {
expect(component.$el.querySelectorAll('.board-card').length).toBe(1); expect(component.$el.querySelectorAll('.board-card').length).toBe(1);
}); });
it('renders link properly in issue', () => {
expect(
component.$el.querySelector('.board-card .board-card-title a').getAttribute('href'),
).not.toContain(':project_path');
});
it('sets data attribute with issue id', () => { it('sets data attribute with issue id', () => {
expect(component.$el.querySelector('.board-card').getAttribute('data-issue-id')).toBe('1'); expect(component.$el.querySelector('.board-card').getAttribute('data-issue-id')).toBe('1');
}); });
......
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