2017-10-04 10:10:24 -04:00
|
|
|
import Vue from 'vue';
|
|
|
|
|
|
|
|
import itemCaretComponent from '~/groups/components/item_caret.vue';
|
|
|
|
|
2018-02-26 14:43:34 -05:00
|
|
|
import mountComponent from 'spec/helpers/vue_mount_component_helper';
|
2017-10-04 10:10:24 -04:00
|
|
|
|
|
|
|
const createComponent = (isGroupOpen = false) => {
|
|
|
|
const Component = Vue.extend(itemCaretComponent);
|
|
|
|
|
|
|
|
return mountComponent(Component, {
|
|
|
|
isGroupOpen,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('ItemCaretComponent', () => {
|
|
|
|
describe('template', () => {
|
|
|
|
it('should render component template correctly', () => {
|
|
|
|
const vm = createComponent();
|
2018-10-09 14:03:09 -04:00
|
|
|
|
2017-10-04 10:10:24 -04:00
|
|
|
expect(vm.$el.classList.contains('folder-caret')).toBeTruthy();
|
2017-12-28 00:35:12 -05:00
|
|
|
expect(vm.$el.querySelectorAll('svg').length).toBe(1);
|
2017-10-04 10:10:24 -04:00
|
|
|
vm.$destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render caret down icon if `isGroupOpen` prop is `true`', () => {
|
|
|
|
const vm = createComponent(true);
|
2018-10-09 14:03:09 -04:00
|
|
|
|
2017-12-28 00:35:12 -05:00
|
|
|
expect(vm.$el.querySelector('svg use').getAttribute('xlink:href')).toContain('angle-down');
|
2017-10-04 10:10:24 -04:00
|
|
|
vm.$destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render caret right icon if `isGroupOpen` prop is `false`', () => {
|
|
|
|
const vm = createComponent();
|
2018-10-09 14:03:09 -04:00
|
|
|
|
2017-12-28 00:35:12 -05:00
|
|
|
expect(vm.$el.querySelector('svg use').getAttribute('xlink:href')).toContain('angle-right');
|
2017-10-04 10:10:24 -04:00
|
|
|
vm.$destroy();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|