Skip to content

Commit b9d1034

Browse files
committed
enhanceEnpoints mock for onCacheEntryAdded functionality and cleanup within test scope
1 parent 5a6213c commit b9d1034

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

packages/toolkit/src/query/tests/useMutation-fixedCacheKey.test.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ describe('fixedCacheKey', () => {
2020
endpoints: (build) => ({
2121
send: build.mutation<string, string | Promise<string>>({
2222
query: (arg) => arg,
23-
onCacheEntryAdded: (arg) => {
24-
onNewCacheEntry(arg)
25-
},
2623
}),
2724
}),
2825
})
@@ -362,6 +359,14 @@ describe('fixedCacheKey', () => {
362359
})
363360

364361
test('using fixedCacheKey should create a new cache entry', async () => {
362+
api.enhanceEndpoints({
363+
endpoints: {
364+
send: {
365+
onCacheEntryAdded: (arg) => onNewCacheEntry(arg),
366+
},
367+
},
368+
})
369+
365370
render(<Component name="C1" fixedCacheKey={'testKey'} />, {
366371
wrapper: storeRef.wrapper,
367372
})
@@ -377,5 +382,13 @@ describe('fixedCacheKey', () => {
377382
})
378383

379384
expect(onNewCacheEntry).toHaveBeenCalledWith('C1')
385+
386+
api.enhanceEndpoints({
387+
endpoints: {
388+
send: {
389+
onCacheEntryAdded: undefined,
390+
},
391+
},
392+
})
380393
})
381394
})

0 commit comments

Comments
 (0)