import { act } from 'react-dom/test-utils' ; import { TestBed } from '@kbn/test/jest' ; import { Phase } from '../../../../common/types' ; const createWaitForValidationAction = ( testBed ) => ( ) => { const { component } = testBed ; act ( ( ) => { jest . runAllTimers ( ) ; } ) ; component . update ( ) ; } ; const createExpectMessagesAction = ( testBed ) => ( expectedMessages , phase ? ) => { const { form } = testBed ; if ( phase ) { expect ( form . getErrorsMessages ( `${ phase }-phase` ) ) . toEqual ( expectedMessages ) ; } else { expect ( form . getErrorsMessages ( ) ) . toEqual ( expectedMessages ) ; } } ; export const createErrorsActions = ( testBed ) => { const { exists } = testBed ; return { errors : { waitForValidation : createWaitForValidationAction ( testBed ) , haveGlobalCallout : ( ) => exists ( 'policyFormErrorsCallout' ) , havePhaseCallout : ( phase ) => exists ( `phaseErrorIndicator-${ phase }` ) , expectMessages : createExpectMessagesAction ( testBed ) , } , } ; } ;