2021-01-29 00:20:46 +05:30
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
|
|
|
|
import { listObj } from 'jest/boards/mock_data';
|
|
|
|
import BoardColumn from '~/boards/components/board_column_new.vue';
|
|
|
|
import { ListType } from '~/boards/constants';
|
|
|
|
import { createStore } from '~/boards/stores';
|
|
|
|
|
|
|
|
describe('Board Column Component', () => {
|
|
|
|
let wrapper;
|
|
|
|
let store;
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
wrapper = null;
|
|
|
|
});
|
|
|
|
|
|
|
|
const createComponent = ({ listType = ListType.backlog, collapsed = false } = {}) => {
|
|
|
|
const boardId = '1';
|
|
|
|
|
|
|
|
const listMock = {
|
|
|
|
...listObj,
|
2021-02-22 17:27:13 +05:30
|
|
|
listType,
|
2021-01-29 00:20:46 +05:30
|
|
|
collapsed,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (listType === ListType.assignee) {
|
|
|
|
delete listMock.label;
|
2021-02-22 17:27:13 +05:30
|
|
|
listMock.assignee = {};
|
2021-01-29 00:20:46 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
store = createStore();
|
|
|
|
|
|
|
|
wrapper = shallowMount(BoardColumn, {
|
|
|
|
store,
|
|
|
|
propsData: {
|
|
|
|
disabled: false,
|
2021-02-22 17:27:13 +05:30
|
|
|
list: listMock,
|
2021-01-29 00:20:46 +05:30
|
|
|
},
|
|
|
|
provide: {
|
|
|
|
boardId,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const isExpandable = () => wrapper.classes('is-expandable');
|
|
|
|
const isCollapsed = () => wrapper.classes('is-collapsed');
|
|
|
|
|
|
|
|
describe('Given different list types', () => {
|
|
|
|
it('is expandable when List Type is `backlog`', () => {
|
|
|
|
createComponent({ listType: ListType.backlog });
|
|
|
|
|
|
|
|
expect(isExpandable()).toBe(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('expanded / collapsed column', () => {
|
|
|
|
it('has class is-collapsed when list is collapsed', () => {
|
|
|
|
createComponent({ collapsed: false });
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
expect(isCollapsed()).toBe(false);
|
2021-01-29 00:20:46 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('does not have class is-collapsed when list is expanded', () => {
|
|
|
|
createComponent({ collapsed: true });
|
|
|
|
|
|
|
|
expect(isCollapsed()).toBe(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|