Debian Codegraph @

install/freeipa-webui/node_modules/@reduxjs/toolkit/src/query/tests/cacheLifecycle.test-d.ts

raw
1 import type { FetchBaseQueryMeta } from '@reduxjs/toolkit/query'
2 import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query'
3
4 const api = createApi({
5 baseQuery: fetchBaseQuery({ baseUrl: 'https://example.com' }),
6 endpoints: () => ({}),
7 })
8
9 describe('type tests', () => {
10 test(`mutation: await cacheDataLoaded, await cacheEntryRemoved (success)`, () => {
11 const extended = api.injectEndpoints({
12 overrideExisting: true,
13 endpoints: (build) => ({
14 injected: build.mutation<number, string>({
15 query: () => '/success',
16 async onCacheEntryAdded(
17 arg,
18 { dispatch, getState, cacheEntryRemoved, cacheDataLoaded },
19 ) {
20 const firstValue = await cacheDataLoaded
21
22 expectTypeOf(firstValue).toMatchTypeOf<{
23 data: number
24 meta?: FetchBaseQueryMeta
25 }>()
26 },
27 }),
28 }),
29 })
30 })
31 })