Skip to content

Commit

Permalink
Fix failing test due to change in renderHook result interface
Browse files Browse the repository at this point in the history
  • Loading branch information
mendaomn committed Apr 18, 2023
1 parent a715524 commit 5dbada8
Showing 1 changed file with 8 additions and 24 deletions.
32 changes: 8 additions & 24 deletions frontend/src/components/__tests__/useLoadingState.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {renderHook} from '@testing-library/react'
import {renderHook, waitFor} from '@testing-library/react'
import {useLoadingState} from '../useLoadingState'
import {Box} from '@cloudscape-design/components'
import React from 'react'
Expand Down Expand Up @@ -44,9 +44,9 @@ jest.mock('../../model', () => {
})

function expectDataToBeRequested() {
expect(mockGetAppConfig).toHaveBeenCalledTimes(1)
expect(mockGetIdentity).toHaveBeenCalledTimes(1)
expect(mockGetVersion).toHaveBeenCalledTimes(1)
waitFor(() => expect(mockGetAppConfig).toHaveBeenCalledTimes(1))
waitFor(() => expect(mockGetIdentity).toHaveBeenCalledTimes(1))
waitFor(() => expect(mockGetVersion).toHaveBeenCalledTimes(1))
}

function expectDataNotToBeRequested() {
Expand Down Expand Up @@ -114,12 +114,7 @@ describe('given a hook to load all the data necessary for the app to boot', () =
})

it('should request the data', async () => {
const {waitForNextUpdate} = renderHook(
() => useLoadingState(<Box></Box>),
{wrapper},
)

await waitForNextUpdate()
renderHook(() => useLoadingState(<Box></Box>), {wrapper})

expectDataToBeRequested()
})
Expand All @@ -139,12 +134,7 @@ describe('given a hook to load all the data necessary for the app to boot', () =
})

it('should request the data', async () => {
const {waitForNextUpdate} = renderHook(
() => useLoadingState(<Box></Box>),
{wrapper},
)

await waitForNextUpdate()
renderHook(() => useLoadingState(<Box></Box>), {wrapper})

expectDataToBeRequested()
})
Expand All @@ -166,12 +156,7 @@ describe('given a hook to load all the data necessary for the app to boot', () =
})

it('should request the data', async () => {
const {waitForNextUpdate} = renderHook(
() => useLoadingState(<Box></Box>),
{wrapper},
)

await waitForNextUpdate()
renderHook(() => useLoadingState(<Box></Box>), {wrapper})

expectDataToBeRequested()
})
Expand Down Expand Up @@ -259,10 +244,9 @@ describe('given a hook to load all the data necessary for the app to boot', () =
done()
})

const {waitForNextUpdate} = renderHook(() => useLoadingState(<></>), {
renderHook(() => useLoadingState(<></>), {
wrapper,
})
waitForNextUpdate()
})
})
})
Expand Down

0 comments on commit 5dbada8

Please sign in to comment.