debian-mirror-gitlab/spec/javascripts/boards/components/board_spec.js

124 lines
3 KiB
JavaScript
Raw Normal View History

2017-09-10 17:25:29 +05:30
import Vue from 'vue';
2018-12-13 13:39:08 +05:30
import Board from '~/boards/components/board';
2019-09-30 21:07:59 +05:30
import List from '~/boards/models/list';
2018-03-17 18:26:18 +05:30
import { mockBoardService } from '../mock_data';
2017-09-10 17:25:29 +05:30
describe('Board component', () => {
let vm;
let el;
2018-12-13 13:39:08 +05:30
beforeEach(done => {
2019-07-07 11:18:12 +05:30
loadFixtures('boards/show.html');
2017-09-10 17:25:29 +05:30
el = document.createElement('div');
document.body.appendChild(el);
2018-03-17 18:26:18 +05:30
gl.boardService = mockBoardService({
boardsEndpoint: '/',
listsEndpoint: '/',
bulkUpdatePath: '/',
boardId: 1,
});
2017-09-10 17:25:29 +05:30
2018-12-13 13:39:08 +05:30
vm = new Board({
2017-09-10 17:25:29 +05:30
propsData: {
boardId: '1',
disabled: false,
issueLinkBase: '/',
rootPath: '/',
list: new List({
id: 1,
position: 0,
title: 'test',
list_type: 'backlog',
}),
},
}).$mount(el);
Vue.nextTick(done);
});
afterEach(() => {
vm.$destroy();
// remove the component from the DOM
document.querySelector('.board').remove();
localStorage.removeItem(`boards.${vm.boardId}.${vm.list.type}.expanded`);
});
it('board is expandable when list type is backlog', () => {
2018-12-13 13:39:08 +05:30
expect(vm.$el.classList.contains('is-expandable')).toBe(true);
2017-09-10 17:25:29 +05:30
});
2019-09-30 21:07:59 +05:30
it('board is expandable when list type is closed', () => {
expect(new List({ id: 1, list_type: 'closed' }).isExpandable).toBe(true);
2017-09-10 17:25:29 +05:30
});
2019-09-30 21:07:59 +05:30
it('board is expandable when list type is label', () => {
expect(new List({ id: 1, list_type: 'closed' }).isExpandable).toBe(true);
});
2017-09-10 17:25:29 +05:30
2019-09-30 21:07:59 +05:30
it('board is not expandable when list type is blank', () => {
expect(new List({ id: 1, list_type: 'blank' }).isExpandable).toBe(false);
2017-09-10 17:25:29 +05:30
});
2019-09-30 21:07:59 +05:30
it('does not collapse when clicking header', done => {
vm.list.isExpanded = true;
2017-09-10 17:25:29 +05:30
vm.$el.querySelector('.board-header').click();
Vue.nextTick(() => {
2019-09-30 21:07:59 +05:30
expect(vm.$el.classList.contains('is-collapsed')).toBe(false);
2017-09-10 17:25:29 +05:30
done();
});
});
2019-09-30 21:07:59 +05:30
it('collapses when clicking the collapse icon', done => {
vm.list.isExpanded = true;
2017-09-10 17:25:29 +05:30
2019-09-30 21:07:59 +05:30
Vue.nextTick()
.then(() => {
vm.$el.querySelector('.board-title-caret').click();
})
2017-09-10 17:25:29 +05:30
.then(() => {
2018-12-13 13:39:08 +05:30
expect(vm.$el.classList.contains('is-collapsed')).toBe(true);
2019-09-30 21:07:59 +05:30
done();
})
.catch(done.fail);
});
2017-09-10 17:25:29 +05:30
2019-09-30 21:07:59 +05:30
it('expands when clicking the expand icon', done => {
vm.list.isExpanded = false;
2017-09-10 17:25:29 +05:30
2019-09-30 21:07:59 +05:30
Vue.nextTick()
.then(() => {
vm.$el.querySelector('.board-title-caret').click();
2017-09-10 17:25:29 +05:30
})
.then(() => {
2019-09-30 21:07:59 +05:30
expect(vm.$el.classList.contains('is-collapsed')).toBe(false);
2017-09-10 17:25:29 +05:30
done();
2018-12-13 13:39:08 +05:30
})
.catch(done.fail);
2017-09-10 17:25:29 +05:30
});
2019-07-07 11:18:12 +05:30
2019-09-30 21:07:59 +05:30
it('is expanded when created', () => {
expect(vm.list.isExpanded).toBe(true);
expect(vm.$el.classList.contains('is-collapsed')).toBe(false);
});
2019-07-07 11:18:12 +05:30
it('does render add issue button', () => {
expect(vm.$el.querySelector('.issue-count-badge-add-button')).not.toBeNull();
});
it('does not render add issue button when list type is blank', done => {
vm.list.type = 'blank';
Vue.nextTick(() => {
expect(vm.$el.querySelector('.issue-count-badge-add-button')).toBeNull();
done();
});
});
2017-09-10 17:25:29 +05:30
});