Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Started to use fullcalendar and I am trying to make a test to test my event component that gets rendered for an event. The problem I am running into is
EventContentArg
. I getting typescript errors that my event property is missing a bunch of things that are not really related for the test to render. How can I fix the following error:
Type '{ id: string; start: Date; end: Date; title: string; backgroundColor: string; borderColor: string; editable: boolean; textColor: string; resourceId: string; extendedProps: { type: { id: number; name: string; }; status: { ...; }; displayProperties: { ...; }; }; }' is missing the following properties from type 'EventApi': _context, _def, _instance, setProp, and 26 more.ts(2740)
main.d.ts(1289, 5): The expected type comes from property 'event' which is declared here on type 'EventContentArg'
Here is part of my component
import { EventContentArg } from '@fullcalendar/react';
export const EventContent = (event: EventContentArg) => {
const { backgroundColor, timeText, view } = event,
{ end, extendedProps, start, title } = event.event,
{ displayProperties } = extendedProps,
slotDuration = view.getOption('slotDuration') as ISlotDuration,
slotDurationNumber = Math.floor(slotDuration.milliseconds / 60000),
appointmentLength = end!.getTime() - start!.getTime(),
duration = Math.floor(appointmentLength / 60000);
return (
<div>My Component</div>
Here is my test
import { render, screen } from '@testing-library/react';
import React from 'react';
import { EventContentArg } from '@fullcalendar/react';
import { EventContent } from '.';
import { events } from '../../actions/mockData';
import { prettyDate } from './EventContent.stories';
test('event renders with all expected data', () => {
let event = events[2];
let timeText = `${prettyDate(event.start)} - ${prettyDate(event.end)}`;
let args: EventContentArg = {
backgroundColor: 'rgb(133,33,51)',
event,
timeText: timeText,
view: {
getOption: () => {
return {
milliseconds: 900000,
render(<EventContent {...args} />);
Here is the events from the mockData
export const events = [
id: '3',
start: new Date(thirdStart),
end: new Date(thirdEnd),
title: 'Hair Coloring', // This would be like the service name
backgroundColor: 'rgb(133,33,51)', // Should be based on event status
borderColor: '#d2d2d2', // For now should be same color as bg
editable: false,
textColor: '#2d2d2d',
resourceId: '2',
extendedProps: {
type: {
id: 1,
name: 'Appointment',
status: {
id: 2,
name: 'Scheduled',
displayProperties: {
attendeeDetails: 'with Kylo Ren',
resourceDetails: 'Chair 2',
eventIcons: [],
–
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.