Skip to content

Commit 844299f

Browse files
author
Lenz Weber
committed
stop using deprecated apis in tests
1 parent b5ed969 commit 844299f

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,7 @@ describe('hooks tests', () => {
864864
expectType<string>(res.requestId)
865865
expectType<() => void>(res.abort)
866866
expectType<() => Promise<{ name: string }>>(res.unwrap)
867+
expectType<() => void>(res.reset)
867868
expectType<() => void>(res.unsubscribe)
868869

869870
// abort the mutation immediately to force an error
@@ -1938,7 +1939,7 @@ describe('hooks with createApi defaults set', () => {
19381939
increment.matchPending,
19391940
increment.matchFulfilled,
19401941
increment.matchPending,
1941-
api.internalActions.unsubscribeMutationResult.match,
1942+
api.internalActions.removeMutationResult.match,
19421943
increment.matchFulfilled
19431944
)
19441945
})

packages/toolkit/src/query/tests/cacheLifecycle.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ describe.each([['query'], ['mutation']] as const)(
6868
expect(onNewCacheEntry).toHaveBeenCalledWith('arg')
6969
expect(onCleanup).not.toHaveBeenCalled()
7070

71-
promise.unsubscribe(), await waitMs()
71+
promise.reset(), await waitMs()
7272
if (type === 'query') {
7373
jest.advanceTimersByTime(59000), await waitMs()
7474
expect(onCleanup).not.toHaveBeenCalled()
@@ -121,7 +121,7 @@ describe.each([['query'], ['mutation']] as const)(
121121
})
122122
expect(onCleanup).not.toHaveBeenCalled()
123123

124-
promise.unsubscribe(), await waitMs()
124+
promise.reset(), await waitMs()
125125
if (type === 'query') {
126126
jest.advanceTimersByTime(59000), await waitMs()
127127
expect(onCleanup).not.toHaveBeenCalled()
@@ -158,7 +158,7 @@ describe.each([['query'], ['mutation']] as const)(
158158
)
159159
expect(onNewCacheEntry).toHaveBeenCalledWith('arg')
160160

161-
promise.unsubscribe(), await waitMs()
161+
promise.reset(), await waitMs()
162162
if (type === 'query') {
163163
jest.advanceTimersByTime(120000), await waitMs()
164164
}
@@ -196,7 +196,7 @@ describe.each([['query'], ['mutation']] as const)(
196196
)
197197

198198
expect(onNewCacheEntry).toHaveBeenCalledWith('arg')
199-
promise.unsubscribe(), await waitMs()
199+
promise.reset(), await waitMs()
200200
if (type === 'query') {
201201
jest.advanceTimersByTime(59000), await waitMs()
202202
expect(onCleanup).not.toHaveBeenCalled()
@@ -242,7 +242,7 @@ describe.each([['query'], ['mutation']] as const)(
242242

243243
expect(onNewCacheEntry).toHaveBeenCalledWith('arg')
244244

245-
promise.unsubscribe(), await waitMs()
245+
promise.reset(), await waitMs()
246246
if (type === 'query') {
247247
jest.advanceTimersByTime(59000), await waitMs()
248248
expect(onCleanup).not.toHaveBeenCalled()
@@ -287,7 +287,7 @@ describe.each([['query'], ['mutation']] as const)(
287287

288288
expect(onNewCacheEntry).toHaveBeenCalledWith('arg')
289289

290-
promise.unsubscribe(), await waitMs()
290+
promise.reset(), await waitMs()
291291
if (type === 'query') {
292292
jest.advanceTimersByTime(59000), await waitMs()
293293
expect(onCleanup).not.toHaveBeenCalled()
@@ -408,7 +408,7 @@ test(`mutation: getCacheEntry`, async () => {
408408
expect(gotFirstValue).toHaveBeenCalled()
409409
})
410410

411-
promise.unsubscribe(), await waitMs()
411+
promise.reset(), await waitMs()
412412

413413
expect(snapshot).toHaveBeenCalledTimes(3)
414414
expect(snapshot.mock.calls[0][0]).toMatchObject({

0 commit comments

Comments
 (0)