File tree Expand file tree Collapse file tree 2 files changed +35
-26
lines changed Expand file tree Collapse file tree 2 files changed +35
-26
lines changed Original file line number Diff line number Diff line change @@ -92,32 +92,6 @@ export const useRenderCounter = () => {
9292 return useCallback ( ( ) => countRef . current , [ ] )
9393}
9494
95- expect . extend ( {
96- toMatchSequence (
97- _actions : UnknownAction [ ] ,
98- ...matchers : Array < ( arg : any ) => boolean >
99- ) {
100- const actions = _actions . concat ( )
101- actions . shift ( ) // remove INIT
102-
103- for ( let i = 0 ; i < matchers . length ; i ++ ) {
104- if ( ! matchers [ i ] ( actions [ i ] ) ) {
105- return {
106- message : ( ) =>
107- `Action ${ actions [ i ] . type } does not match sequence at position ${ i } .
108- All actions:
109- ${ actions . map ( ( a ) => a . type ) . join ( '\n' ) } `,
110- pass : false ,
111- }
112- }
113- }
114- return {
115- message : ( ) => `All actions match the sequence.` ,
116- pass : true ,
117- }
118- } ,
119- } )
120-
12195export const actionsReducer = {
12296 actions : ( state : UnknownAction [ ] = [ ] , action : UnknownAction ) => {
12397 // As of 2.0-beta.4, we are going to ignore all `subscriptionsUpdated` actions in tests
Original file line number Diff line number Diff line change 1+ import type { UnknownAction } from '@reduxjs/toolkit'
12import nodeFetch , { Headers , Request } from 'node-fetch'
23import { server } from './src/query/tests/mocks/server'
34
@@ -58,3 +59,37 @@ afterEach(() => {
5859afterAll ( ( ) => {
5960 server . close ( )
6061} )
62+
63+ declare global {
64+ namespace jest {
65+ interface Matchers < R > {
66+ toMatchSequence ( ...matchers : Array < ( arg : any ) => boolean > ) : R
67+ }
68+ }
69+ }
70+
71+ expect . extend ( {
72+ toMatchSequence (
73+ _actions : UnknownAction [ ] ,
74+ ...matchers : Array < ( arg : any ) => boolean >
75+ ) {
76+ const actions = _actions . concat ( )
77+ actions . shift ( ) // remove INIT
78+
79+ for ( let i = 0 ; i < matchers . length ; i ++ ) {
80+ if ( ! matchers [ i ] ( actions [ i ] ) ) {
81+ return {
82+ message : ( ) =>
83+ `Action ${ actions [ i ] . type } does not match sequence at position ${ i } .
84+ All actions:
85+ ${ actions . map ( ( a ) => a . type ) . join ( '\n' ) } `,
86+ pass : false ,
87+ }
88+ }
89+ }
90+ return {
91+ message : ( ) => `All actions match the sequence.` ,
92+ pass : true ,
93+ }
94+ } ,
95+ } )
You can’t perform that action at this time.
0 commit comments