debian-mirror-gitlab/spec/frontend/vue_shared/components/pikaday_spec.js

43 lines
1 KiB
JavaScript
Raw Normal View History

2020-06-23 00:09:42 +05:30
import { shallowMount } from '@vue/test-utils';
2020-01-01 13:55:28 +05:30
import datePicker from '~/vue_shared/components/pikaday.vue';
2018-03-17 18:26:18 +05:30
describe('datePicker', () => {
2020-06-23 00:09:42 +05:30
let wrapper;
2018-03-17 18:26:18 +05:30
beforeEach(() => {
2020-06-23 00:09:42 +05:30
wrapper = shallowMount(datePicker, {
propsData: {
label: 'label',
},
attachToDocument: true,
2018-03-17 18:26:18 +05:30
});
});
2020-06-23 00:09:42 +05:30
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
2018-03-17 18:26:18 +05:30
it('should render label text', () => {
2020-06-23 00:09:42 +05:30
expect(
wrapper
.find('.dropdown-toggle-text')
.text()
.trim(),
).toEqual('label');
2018-03-17 18:26:18 +05:30
});
it('should show calendar', () => {
2020-06-23 00:09:42 +05:30
expect(wrapper.find('.pika-single').element).toBeDefined();
2018-03-17 18:26:18 +05:30
});
2020-06-23 00:09:42 +05:30
it('should emit hidePicker event when dropdown is clicked', () => {
// Removing the bootstrap data-toggle property,
// because it interfers with our click event
delete wrapper.find('.dropdown-menu-toggle').element.dataset.toggle;
2018-03-17 18:26:18 +05:30
2020-06-23 00:09:42 +05:30
wrapper.find('.dropdown-menu-toggle').trigger('click');
2018-12-13 13:39:08 +05:30
2020-06-23 00:09:42 +05:30
expect(wrapper.emitted('hidePicker')).toEqual([[]]);
2018-03-17 18:26:18 +05:30
});
});