Skip to content

Commit 9babc09

Browse files
committed
Fix failing test due to change in renderHook result interface
1 parent ff787f7 commit 9babc09

File tree

1 file changed

+8
-24
lines changed

1 file changed

+8
-24
lines changed

frontend/src/components/__tests__/useLoadingState.test.tsx

+8-24
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {renderHook} from '@testing-library/react'
1+
import {renderHook, waitFor} from '@testing-library/react'
22
import {useLoadingState} from '../useLoadingState'
33
import {Box} from '@cloudscape-design/components'
44
import React from 'react'
@@ -44,9 +44,9 @@ jest.mock('../../model', () => {
4444
})
4545

4646
function expectDataToBeRequested() {
47-
expect(mockGetAppConfig).toHaveBeenCalledTimes(1)
48-
expect(mockGetIdentity).toHaveBeenCalledTimes(1)
49-
expect(mockGetVersion).toHaveBeenCalledTimes(1)
47+
waitFor(() => expect(mockGetAppConfig).toHaveBeenCalledTimes(1))
48+
waitFor(() => expect(mockGetIdentity).toHaveBeenCalledTimes(1))
49+
waitFor(() => expect(mockGetVersion).toHaveBeenCalledTimes(1))
5050
}
5151

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

116116
it('should request the data', async () => {
117-
const {waitForNextUpdate} = renderHook(
118-
() => useLoadingState(<Box></Box>),
119-
{wrapper},
120-
)
121-
122-
await waitForNextUpdate()
117+
renderHook(() => useLoadingState(<Box></Box>), {wrapper})
123118

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

141136
it('should request the data', async () => {
142-
const {waitForNextUpdate} = renderHook(
143-
() => useLoadingState(<Box></Box>),
144-
{wrapper},
145-
)
146-
147-
await waitForNextUpdate()
137+
renderHook(() => useLoadingState(<Box></Box>), {wrapper})
148138

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

168158
it('should request the data', async () => {
169-
const {waitForNextUpdate} = renderHook(
170-
() => useLoadingState(<Box></Box>),
171-
{wrapper},
172-
)
173-
174-
await waitForNextUpdate()
159+
renderHook(() => useLoadingState(<Box></Box>), {wrapper})
175160

176161
expectDataToBeRequested()
177162
})
@@ -259,10 +244,9 @@ describe('given a hook to load all the data necessary for the app to boot', () =
259244
done()
260245
})
261246

262-
const {waitForNextUpdate} = renderHook(() => useLoadingState(<></>), {
247+
renderHook(() => useLoadingState(<></>), {
263248
wrapper,
264249
})
265-
waitForNextUpdate()
266250
})
267251
})
268252
})

0 commit comments

Comments
 (0)