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 collapsedGroupedDatePicker from '~/vue_shared/components/sidebar/collapsed_grouped_date_picker.vue';
|
2017-11-10 23:41:04 +00:00
|
|
|
|
|
|
|
describe('collapsedGroupedDatePicker', () => {
|
|
|
|
let vm;
|
|
|
|
beforeEach(() => {
|
|
|
|
const CollapsedGroupedDatePicker = Vue.extend(collapsedGroupedDatePicker);
|
|
|
|
vm = mountComponent(CollapsedGroupedDatePicker, {
|
|
|
|
showToggleSidebar: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-01-23 15:19:56 +00:00
|
|
|
describe('toggleCollapse events', () => {
|
2020-12-23 21:10:24 +00:00
|
|
|
beforeEach((done) => {
|
2019-04-26 12:54:20 +00:00
|
|
|
jest.spyOn(vm, 'toggleSidebar').mockImplementation(() => {});
|
2017-11-10 23:41:04 +00:00
|
|
|
vm.minDate = new Date('07/17/2016');
|
|
|
|
Vue.nextTick(done);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should emit when collapsed-calendar-icon is clicked', () => {
|
|
|
|
vm.$el.querySelector('.sidebar-collapsed-icon').click();
|
2018-10-09 18:03:09 +00:00
|
|
|
|
2018-01-23 15:19:56 +00:00
|
|
|
expect(vm.toggleSidebar).toHaveBeenCalled();
|
2017-11-10 23:41:04 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('minDate and maxDate', () => {
|
2020-12-23 21:10:24 +00:00
|
|
|
beforeEach((done) => {
|
2017-11-10 23:41:04 +00:00
|
|
|
vm.minDate = new Date('07/17/2016');
|
|
|
|
vm.maxDate = new Date('07/17/2017');
|
|
|
|
Vue.nextTick(done);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render both collapsed-calendar-icon', () => {
|
|
|
|
const icons = vm.$el.querySelectorAll('.sidebar-collapsed-icon');
|
2018-10-09 18:03:09 +00:00
|
|
|
|
2017-11-10 23:41:04 +00:00
|
|
|
expect(icons.length).toEqual(2);
|
|
|
|
expect(icons[0].innerText.trim()).toEqual('Jul 17 2016');
|
|
|
|
expect(icons[1].innerText.trim()).toEqual('Jul 17 2017');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('minDate', () => {
|
2020-12-23 21:10:24 +00:00
|
|
|
beforeEach((done) => {
|
2017-11-10 23:41:04 +00:00
|
|
|
vm.minDate = new Date('07/17/2016');
|
|
|
|
Vue.nextTick(done);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render minDate in collapsed-calendar-icon', () => {
|
|
|
|
const icons = vm.$el.querySelectorAll('.sidebar-collapsed-icon');
|
2018-10-09 18:03:09 +00:00
|
|
|
|
2017-11-10 23:41:04 +00:00
|
|
|
expect(icons.length).toEqual(1);
|
|
|
|
expect(icons[0].innerText.trim()).toEqual('From Jul 17 2016');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('maxDate', () => {
|
2020-12-23 21:10:24 +00:00
|
|
|
beforeEach((done) => {
|
2017-11-10 23:41:04 +00:00
|
|
|
vm.maxDate = new Date('07/17/2017');
|
|
|
|
Vue.nextTick(done);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render maxDate in collapsed-calendar-icon', () => {
|
|
|
|
const icons = vm.$el.querySelectorAll('.sidebar-collapsed-icon');
|
2018-10-09 18:03:09 +00:00
|
|
|
|
2017-11-10 23:41:04 +00:00
|
|
|
expect(icons.length).toEqual(1);
|
|
|
|
expect(icons[0].innerText.trim()).toEqual('Until Jul 17 2017');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('no dates', () => {
|
|
|
|
it('should render None', () => {
|
|
|
|
const icons = vm.$el.querySelectorAll('.sidebar-collapsed-icon');
|
2018-10-09 18:03:09 +00:00
|
|
|
|
2017-11-10 23:41:04 +00:00
|
|
|
expect(icons.length).toEqual(1);
|
|
|
|
expect(icons[0].innerText.trim()).toEqual('None');
|
|
|
|
});
|
2018-10-29 08:01:50 +00:00
|
|
|
|
|
|
|
it('should have tooltip as `Start and due date`', () => {
|
|
|
|
const icons = vm.$el.querySelectorAll('.sidebar-collapsed-icon');
|
|
|
|
|
2020-10-15 15:08:45 +00:00
|
|
|
expect(icons[0].title).toBe('Start and due date');
|
2018-10-29 08:01:50 +00:00
|
|
|
});
|
2017-11-10 23:41:04 +00:00
|
|
|
});
|
|
|
|
});
|