2017-11-10 23:41:04 +00:00
|
|
|
import Vue from 'vue';
|
2019-04-26 12:54:20 +00:00
|
|
|
import mountComponent from 'helpers/vue_mount_component_helper';
|
2019-12-09 12:07:58 +00:00
|
|
|
import collapsedCalendarIcon from '~/vue_shared/components/sidebar/collapsed_calendar_icon.vue';
|
2017-11-10 23:41:04 +00:00
|
|
|
|
|
|
|
describe('collapsedCalendarIcon', () => {
|
|
|
|
let vm;
|
|
|
|
beforeEach(() => {
|
|
|
|
const CollapsedCalendarIcon = Vue.extend(collapsedCalendarIcon);
|
|
|
|
vm = mountComponent(CollapsedCalendarIcon, {
|
|
|
|
containerClass: 'test-class',
|
|
|
|
text: 'text',
|
|
|
|
showIcon: false,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should add class to container', () => {
|
|
|
|
expect(vm.$el.classList.contains('test-class')).toEqual(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should hide calendar icon if showIcon', () => {
|
2020-10-15 09:08:41 +00:00
|
|
|
expect(vm.$el.querySelector('[data-testid="calendar-icon"]')).toBeNull();
|
2017-11-10 23:41:04 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should render text', () => {
|
|
|
|
expect(vm.$el.querySelector('span').innerText.trim()).toEqual('text');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should emit click event when container is clicked', () => {
|
2019-04-26 12:54:20 +00:00
|
|
|
const click = jest.fn();
|
2017-11-10 23:41:04 +00:00
|
|
|
vm.$on('click', click);
|
|
|
|
|
|
|
|
vm.$el.click();
|
2018-10-09 18:03:09 +00:00
|
|
|
|
2017-11-10 23:41:04 +00:00
|
|
|
expect(click).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
});
|