Fullcalendar.io 显示更多链接(dayMaxEvents) 测试在 vue 测试库中不起作用
我使用完整日历 v5 和testing-library/vue 进行测试。我尝试测试在弹出窗口中显示更多事件。但是,尽管我提供的事件超过 4 个,但显示更多链接并未加载到日历上,并且 moreLinkDidMount 函数永远无法工作。 当我将 daymaxEvents 属性设置为零时,它会显示链接并且 moreLinkDidMount 函数可以工作。我缺少什么?
这是我的代码;
import FullCalendar from '@fullcalendar/vue';
import dayGridPlugin from '@fullcalendar/daygrid';
import trLocale from '@fullcalendar/core/locales/tr';
<FullCalendar :options="calendarOptions" />
data () {
return {
calendarOptions: {
eventDisplay: 'block',
headerToolbar: false,
dayHeaders: false,
locales: [trLocale],
plugins: [ dayGridPlugin ],
initialView: 'dayGridMonth',
weekends: true,
dayMaxEvents: 4,
dayPopoverFormat: { day: 'numeric' },
displayEventTime: false,
events: [],
moreLinkDidMount: (arg) => {
console.log(arg);
},
},
};
},
async mounted () {
await this.getAllEvents();
},
async getAllEvents () {
const startDate = this.currentStartDate;
const endDate = this.currentEndDate;
await this.getEvents({ startDate, endDate }); // Data that comes from API are added in
calendar options events
},
这是我的测试代码;
import { screen, waitFor,render } from '@testing-library/vue';
import FullCalendar from '@/views/Calendar/FullCalendar';
import { getMockEventItem } from '../../../mocks/eventItem.mock';
it('should show more link when event count is bigger than 4', async () => {
// given
const events = [
getMockEventItem(),
getMockEventItem(),
getMockEventItem(),
getMockEventItem(),
getMockEventItem(),
];
calendarService.getEvents.mockResolvedValue(events);
render(FullCalendar);
await waitFor(() => {
expect(document.querySelector('.fc-daygrid-more-link.fc-more-link')).toBeInTheDocument();
});
});
I am using full calendar v5 and testing-library/vue for tests. I try to test show more events in the popover. But although I am giving events more than 4 the show more link isn't being loaded on the calendar and it never works the moreLinkDidMount function.
When I set the daymaxEvents prop as zero it shows the link and the moreLinkDidMount function works. What am I missing?
Here are my codes;
import FullCalendar from '@fullcalendar/vue';
import dayGridPlugin from '@fullcalendar/daygrid';
import trLocale from '@fullcalendar/core/locales/tr';
<FullCalendar :options="calendarOptions" />
data () {
return {
calendarOptions: {
eventDisplay: 'block',
headerToolbar: false,
dayHeaders: false,
locales: [trLocale],
plugins: [ dayGridPlugin ],
initialView: 'dayGridMonth',
weekends: true,
dayMaxEvents: 4,
dayPopoverFormat: { day: 'numeric' },
displayEventTime: false,
events: [],
moreLinkDidMount: (arg) => {
console.log(arg);
},
},
};
},
async mounted () {
await this.getAllEvents();
},
async getAllEvents () {
const startDate = this.currentStartDate;
const endDate = this.currentEndDate;
await this.getEvents({ startDate, endDate }); // Data that comes from API are added in
calendar options events
},
Here are my test codes;
import { screen, waitFor,render } from '@testing-library/vue';
import FullCalendar from '@/views/Calendar/FullCalendar';
import { getMockEventItem } from '../../../mocks/eventItem.mock';
it('should show more link when event count is bigger than 4', async () => {
// given
const events = [
getMockEventItem(),
getMockEventItem(),
getMockEventItem(),
getMockEventItem(),
getMockEventItem(),
];
calendarService.getEvents.mockResolvedValue(events);
render(FullCalendar);
await waitFor(() => {
expect(document.querySelector('.fc-daygrid-more-link.fc-more-link')).toBeInTheDocument();
});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论