import { printExpectation } from '../print' ; import { Property } from '../proxy' ; import { Expectation , ReturnValue } from './expectation' ; import { Matcher } from './matcher' ; example export class StrongExpectation implements Expectation { private matched = 0 ; public min : number = 1 ; public max : number = 1 ; constructor ( public property , public args , public returnValue ) { } setInvocationCount ( min , max = 1 ) { this . min = min ; this . max = max ; } matches ( args ) { if ( ! this . matchesArgs ( args ) ) { return false ; } this . matched ++ ; return this . max === 0 || this . matched <= this . max ; } isUnmet ( ) { return this . matched < this . min ; } private matchesArgs ( received ) { if ( this . args === undefined ) { return ! received ; } if ( ! received ) { return false ; } return this . args . every ( ( arg , i ) => arg . matches ( received [ i ] ) ) ; } toJSON ( ) { return printExpectation ( this . property , this . args , this . returnValue , this . min , this . max ) ; } }