2018-03-17 18:26:18 +05:30
|
|
|
import Vue from 'vue';
|
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
import mountComponent from 'spec/helpers/vue_mount_component_helper';
|
2020-01-01 13:55:28 +05:30
|
|
|
import itemTypeIconComponent from '~/groups/components/item_type_icon.vue';
|
2018-03-17 18:26:18 +05:30
|
|
|
import { ITEM_TYPE } from '../mock_data';
|
|
|
|
|
|
|
|
const createComponent = (itemType = ITEM_TYPE.GROUP, isGroupOpen = false) => {
|
|
|
|
const Component = Vue.extend(itemTypeIconComponent);
|
|
|
|
|
|
|
|
return mountComponent(Component, {
|
|
|
|
itemType,
|
|
|
|
isGroupOpen,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('ItemTypeIconComponent', () => {
|
|
|
|
describe('template', () => {
|
|
|
|
it('should render component template correctly', () => {
|
|
|
|
const vm = createComponent();
|
|
|
|
vm.$mount();
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(vm.$el.classList.contains('item-type-icon')).toBeTruthy();
|
|
|
|
vm.$destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render folder open or close icon based `isGroupOpen` prop value', () => {
|
|
|
|
let vm;
|
|
|
|
|
|
|
|
vm = createComponent(ITEM_TYPE.GROUP, true);
|
|
|
|
vm.$mount();
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(vm.$el.querySelector('use').getAttribute('xlink:href')).toContain('folder-open');
|
|
|
|
vm.$destroy();
|
|
|
|
|
|
|
|
vm = createComponent(ITEM_TYPE.GROUP);
|
|
|
|
vm.$mount();
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(vm.$el.querySelector('use').getAttribute('xlink:href')).toContain('folder');
|
|
|
|
vm.$destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render bookmark icon based on `isProject` prop value', () => {
|
|
|
|
let vm;
|
|
|
|
|
|
|
|
vm = createComponent(ITEM_TYPE.PROJECT);
|
|
|
|
vm.$mount();
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(vm.$el.querySelector('use').getAttribute('xlink:href')).toContain('bookmark');
|
|
|
|
vm.$destroy();
|
|
|
|
|
|
|
|
vm = createComponent(ITEM_TYPE.GROUP);
|
|
|
|
vm.$mount();
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(vm.$el.querySelector('use').getAttribute('xlink:href')).not.toContain('bookmark');
|
|
|
|
vm.$destroy();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|