import { mockFlashMessageHelpers } from '../__mocks__/kea_logic' ; import { nextTick } from '@kbn/test/jest' ; import { HttpHandler } from 'src/core/public' ; export const itShowsServerErrorAsFlashMessage = ( httpMethod , callback ) => { const { flashAPIErrors } = mockFlashMessageHelpers ; it ( 'shows any server errors as flash messages' , async ( ) => { ( httpMethod as jest . Mock ) . mockReturnValueOnce ( Promise . reject ( 'error' ) ) ; callback ( ) ; await nextTick ( ) ; expect ( flashAPIErrors ) . toHaveBeenCalledWith ( 'error' ) ; } ) ; } ;