import RootActions from 'actions' ; export default async function testReducer < T , A extends RootActions > ( reducer , callback ) { describe ( reducer . name , ( ) => { it ( 'returns initial state' , ( ) => { expect ( reducer ( undefined , { } as any ) ) . toMatchSnapshot ( ) ; } ) ; callback ( testReducer ) ; } ) ; function testReducer ( initialState , action , expectedState , customItName ? ) { it ( customItName || `handles ${ action . type }` , ( ) => { expect . hasAssertions ( ) ; const newState = reducer ( ( initialState as Readonly < T > ) || void 0 , action ) ; if ( typeof expectedState === 'function' ) { expectedState ( newState ) ; return ; } expect ( newState ) . toEqual ( expect . objectContaining ( expectedState ) ) ; } ) ; } }