Skip to content

Commit

Permalink
test(usePersistedStateReducer): await act in other retry logic test
Browse files Browse the repository at this point in the history
  • Loading branch information
KaylaBrady committed Aug 22, 2023
1 parent 7acc57d commit e039e78
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions assets/tests/hooks/usePersistedStateReducer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
beforeEach,
afterAll,
} from "@jest/globals"
import { act, renderHook, waitFor } from "@testing-library/react"
import { act, renderHook } from "@testing-library/react"
import { putUserSetting, putRouteTabs } from "../../src/api"
import appData from "../../src/appData"
import usePersistedStateReducer, {
Expand Down Expand Up @@ -351,16 +351,13 @@ describe("usePersistedStateReducer", () => {
.mockImplementationOnce(() => fakePromise)
.mockImplementationOnce(() => fakePromise)

act(() => {
await act(async () => {
dispatch(createRouteTab())
})
const initialValue = result.current
await waitFor(() => {
expect(result.current).not.toBe(initialValue)
})

const [state] = result.current

expect(putRouteTabs).toHaveBeenCalledTimes(3)
expect(state.routeTabs).toMatchObject([
{
ordering: 0,
Expand All @@ -370,7 +367,6 @@ describe("usePersistedStateReducer", () => {
expect(state.routeTabsToPush).toBeNull()
expect(state.routeTabsToPushNext).toBeNull()
expect(state.routeTabsPushInProgress).toEqual(false)
expect(putRouteTabs).toHaveBeenCalledTimes(3)
})
})

Expand Down

0 comments on commit e039e78

Please sign in to comment.