Skip to content

Commit

Permalink
disabled test for React 16
Browse files Browse the repository at this point in the history
  • Loading branch information
arshaw committed Sep 21, 2023
1 parent 91746f6 commit d6592f6
Showing 1 changed file with 53 additions and 1 deletion.
54 changes: 53 additions & 1 deletion tests/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect, useContext, useCallback, createContext } from 'react'
import React, { useState, useEffect, useContext, useCallback, createContext, useRef } from 'react'
import { act } from 'react-dom/test-utils'
import { render } from '@testing-library/react'
import FullCalendar from '../dist/index.js'
Expand Down Expand Up @@ -663,6 +663,58 @@ it('custom view receives enough props for slicing', () => {
expect(container.querySelector('.custom-view-events').innerText).toBe('1 events')
})

// https://github.com/fullcalendar/fullcalendar/issues/7448
// Only in React 16
xit('allows useEffect to call API methods without throwing error', (done) => {
const initialDate = new Date(Date.UTC(2023, 8, 21))
let dateEffectCnt = 0

function TestApp() {
const ref = useRef()
const [date, setDate] = useState(initialDate)

function incrementDate() {
const nextDate = new Date(Date.UTC(
date.getUTCFullYear(),
date.getUTCMonth(),
date.getUTCDate() + 1,
))
setDate(nextDate)
}

// on initial render
useEffect(() => {
incrementDate()
}, [])

useEffect(() => {
dateEffectCnt++
ref.current.getApi().gotoDate(date)
}, [date])

return (
<FullCalendar
ref={ref}
plugins={[dayGridPlugin]}
initialView='dayGridDay'
initialDate={initialDate}
timeZone='UTC'
/>
)
}

render(
<React.StrictMode>
<TestApp />
</React.StrictMode>
)

setTimeout(() => {
expect(dateEffectCnt).toBe(1)
done()
}, 100)
})

// FullCalendar data utils
// -------------------------------------------------------------------------------------------------

Expand Down

0 comments on commit d6592f6

Please sign in to comment.