import { UnexpectedCalls , UnmetExpectations } from '../errors' ; import { ExpectationRepository } from '../expectation/repository/expectation-repository' ; import { getAllMocks , getMockState } from '../mock/map' ; import { Mock } from '../mock/mock' ; export const verifyRepo = ( repository ) => { const unmetExpectations = repository . getUnmet ( ) ; if ( unmetExpectations . length ) { throw new UnmetExpectations ( unmetExpectations ) ; } const callStats = repository . getCallStats ( ) ; if ( callStats . unexpected . size ) { throw new UnexpectedCalls ( callStats . unexpected , unmetExpectations ) ; } } ; throws throws example export const verify = < T > ( mock ) : void => { const { repository } = getMockState ( mock ) ; verifyRepo ( repository ) ; } ; see verify export const verifyAll = ( ) : void => { getAllMocks ( ) . forEach ( ( [ mock ] ) => { verify ( mock ) ; } ) ; } ;