mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-09 00:42:36 +00:00
Fixed #3802 - Improve folder structure for nuxt configurations
This commit is contained in:
parent
851950270b
commit
f5fe822afb
563 changed files with 1703 additions and 1095 deletions
80
components/lib/calendar/Calendar.spec.js
Normal file
80
components/lib/calendar/Calendar.spec.js
Normal file
|
@ -0,0 +1,80 @@
|
|||
import { mount } from '@vue/test-utils';
|
||||
import PrimeVue from 'primevue/config';
|
||||
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 = vi.spyOn(wrapper.vm, 'onDateSelect');
|
||||
|
||||
await wrapper.vm.onDateSelect({ currentTarget: { focus: () => {} } }, event);
|
||||
expect(onDateSelect).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should calculate the correct view date when in range mode', async () => {
|
||||
const dateOne = new Date();
|
||||
const dateTwo = new Date();
|
||||
|
||||
dateTwo.setFullYear(dateOne.getFullYear(), dateOne.getMonth(), dateOne.getDate() + 1);
|
||||
await wrapper.setProps({ selectionMode: 'range', showTime: true, modelValue: [dateOne, dateTwo] });
|
||||
|
||||
expect(wrapper.vm.viewDate).toEqual(dateTwo);
|
||||
});
|
||||
|
||||
it('should respect custom icon settings', async () => {
|
||||
await wrapper.setProps({
|
||||
previousIcon: 'pi pi-discord',
|
||||
nextIcon: 'pi pi-facebook',
|
||||
incrementIcon: 'pi pi-linkedin',
|
||||
decrementIcon: 'pi pi-microsoft',
|
||||
inline: true
|
||||
});
|
||||
|
||||
const previousIcon = wrapper.find('.p-datepicker-prev-icon');
|
||||
const nextIcon = wrapper.find('.p-datepicker-next-icon');
|
||||
|
||||
expect(previousIcon.classes()).toContain('pi-discord');
|
||||
expect(nextIcon.classes()).toContain('pi-facebook');
|
||||
|
||||
await wrapper.setProps({
|
||||
timeOnly: true,
|
||||
hourFormat: '12'
|
||||
});
|
||||
|
||||
expect(wrapper.findAll('.pi-linkedin')).toHaveLength(3);
|
||||
expect(wrapper.findAll('.pi-microsoft')).toHaveLength(3);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue