File tree Expand file tree Collapse file tree 1 file changed +24
-4
lines changed
packages/toolkit/src/tests/utils Expand file tree Collapse file tree 1 file changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -7,16 +7,15 @@ import type {
7
7
} from '@reduxjs/toolkit'
8
8
import { configureStore } from '@reduxjs/toolkit'
9
9
import { setupListeners } from '@reduxjs/toolkit/query'
10
- import { useCallback , useEffect , useRef } from 'react'
11
-
12
- import { Provider } from 'react-redux'
13
-
14
10
import { act , cleanup } from '@testing-library/react'
15
11
import {
16
12
createConsole ,
17
13
getLog ,
18
14
mockConsole ,
19
15
} from 'console-testing-library/pure'
16
+ import { useCallback , useEffect , useRef } from 'react'
17
+ import { Provider } from 'react-redux'
18
+ import type { AnyObject } from '../../tsHelpers'
20
19
21
20
export const ANY = 0 as any
22
21
@@ -268,3 +267,24 @@ export function setupApiStore<
268
267
269
268
return refObj
270
269
}
270
+
271
+ export const isObject = ( value : unknown ) : value is AnyObject => {
272
+ return typeof value === 'object' && value != null
273
+ }
274
+
275
+ export const hasBodyAndHeaders = (
276
+ request : unknown ,
277
+ ) : request is {
278
+ body : any
279
+ headers : {
280
+ 'content-type' : string
281
+ }
282
+ } => {
283
+ return (
284
+ isObject ( request ) &&
285
+ 'headers' in request &&
286
+ isObject ( request . headers ) &&
287
+ 'content-type' in request . headers &&
288
+ 'body' in request
289
+ )
290
+ }
You can’t perform that action at this time.
0 commit comments