import { isMatcher } from '../expectation/matcher' ; import { ExpectationRepository } from '../expectation/repository/expectation-repository' ; import { StrongRepository } from '../expectation/repository/strong-repository' ; import { StrongExpectation } from '../expectation/strong-expectation' ; import { ExpectationFactory , RepoSideEffectPendingExpectation , } from '../when/pending-expectation' ; import { currentDefaults } from './defaults' ; import { setMockState } from './map' ; import { createStub } from './stub' ; export type Mock < T > = T ; const strongExpectationFactory = ( property , args , returnValue ) => new StrongExpectation ( property , args ?. map ( ( arg ) => ( isMatcher ( arg ) ? arg : currentDefaults . matcher ( arg ) ) ) , returnValue ) ; interface MockOptions { /**
     * You can provide your own repository to store and find expectations.
     */ repository ? : ExpectationRepository ; /**
     * You can provide your own way of creating expectations.
     */ expectationFactory ? : ExpectationFactory ; } example export const mock = < T > ( { repository = new StrongRepository ( ) , expectationFactory = strongExpectationFactory , } = { } ) : Mock < T > => { const pendingExpectation = new RepoSideEffectPendingExpectation ( expectationFactory ) ; const stub = createStub < T > ( repository , pendingExpectation ) ; setMockState ( stub , { repository , pendingExpectation } ) ; return stub ; } ;