Skip to content

Commit b87f710

Browse files
committed
Fix delay related issues inside optimisticUpserts.test.tsx
1 parent 2154d33 commit b87f710

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/toolkit/src/query/tests/optimisticUpserts.test.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
setupApiStore,
77
waitMs,
88
} from '../../tests/utils/helpers'
9+
import { delay } from '../../utils'
910

1011
interface Post {
1112
id: string
@@ -52,7 +53,7 @@ const api = createApi({
5253
}),
5354
post2: build.query<Post, string>({
5455
queryFn: async (id) => {
55-
await waitMs(20)
56+
await delay(20)
5657
return {
5758
data: {
5859
id,
@@ -276,7 +277,7 @@ describe('upsertQueryData', () => {
276277
title: 'All about cheese.',
277278
contents: 'Yummy',
278279
}
279-
baseQuery.mockImplementation(() => waitMs(20).then(() => fetchedData))
280+
baseQuery.mockImplementation(() => delay(20).then(() => fetchedData))
280281
const upsertedData = {
281282
id: '3',
282283
title: 'Data from a SSR Render',
@@ -299,7 +300,7 @@ describe('upsertQueryData', () => {
299300
})
300301
test('upsert while a normal query is running (rejected)', async () => {
301302
baseQuery.mockImplementationOnce(async () => {
302-
await waitMs(20)
303+
await delay(20)
303304
// eslint-disable-next-line no-throw-literal
304305
throw 'Error!'
305306
})

0 commit comments

Comments
 (0)