Calendar test added

pull/2305/head
Tuğçe Küçükoğlu 2022-03-10 13:08:29 +03:00 committed by Tuğçe Küçükoğlu
parent 23bcb44594
commit 75f9d05852
1 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,45 @@
import { mount } from '@vue/test-utils';
import PrimeVue from '@/components/config/PrimeVue';
import Calendar from './Calendar.vue';
describe('Calendar.vue', () => {
let wrapper;
beforeEach(() => {
wrapper = mount(Calendar, {
global: {
plugins: [PrimeVue],
stubs: {
teleport: true
}
},
props: {
modelValue: new Date()
}
});
});
it('should exist', async() => {
expect(wrapper.find('.p-calendar.p-component').exists()).toBe(true);
expect(wrapper.find('.p-inputtext').exists()).toBe(true);
let input = wrapper.find('.p-inputtext');
await input.trigger('focus');
expect(wrapper.find('.p-datepicker.p-component').exists()).toBe(true);
expect(wrapper.find('.p-datepicker-today').exists()).toBe(true);
expect(wrapper.find('.p-highlight').exists()).toBe(true);
expect(wrapper.find('.p-highlight').text()).toEqual(new Date().getDate().toString());
});
it('should select a date', async () => {
await wrapper.setProps({ inline: true });
const event = {day: 8, month: 2, year: 2022, today: false, selectable: true};
const onDateSelect = jest.spyOn(wrapper.vm, 'onDateSelect');
await wrapper.vm.onDateSelect({currentTarget: {focus: () => {}}}, event);
expect(onDateSelect).toHaveBeenCalled()
});
});