2018-03-17 18:26:18 +05:30
|
|
|
import Vue from 'vue';
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
import mountComponent from 'helpers/vue_mount_component_helper';
|
2020-01-01 13:55:28 +05:30
|
|
|
import itemCaretComponent from '~/groups/components/item_caret.vue';
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
const createComponent = (isGroupOpen = false) => {
|
|
|
|
const Component = Vue.extend(itemCaretComponent);
|
|
|
|
|
|
|
|
return mountComponent(Component, {
|
|
|
|
isGroupOpen,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('ItemCaretComponent', () => {
|
2020-05-24 23:13:21 +05:30
|
|
|
let vm;
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
vm.$destroy();
|
|
|
|
});
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
describe('template', () => {
|
|
|
|
it('should render component template correctly', () => {
|
2020-05-24 23:13:21 +05:30
|
|
|
vm = createComponent();
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(vm.$el.classList.contains('folder-caret')).toBeTruthy();
|
|
|
|
expect(vm.$el.querySelectorAll('svg').length).toBe(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render caret down icon if `isGroupOpen` prop is `true`', () => {
|
2020-05-24 23:13:21 +05:30
|
|
|
vm = createComponent(true);
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(vm.$el.querySelector('svg use').getAttribute('xlink:href')).toContain('angle-down');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render caret right icon if `isGroupOpen` prop is `false`', () => {
|
2020-05-24 23:13:21 +05:30
|
|
|
vm = createComponent();
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(vm.$el.querySelector('svg use').getAttribute('xlink:href')).toContain('angle-right');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|