mockt
Version:
Joyful mocking library for Typescript and Javascript
3 lines (2 loc) • 24.6 kB
JavaScript
"use strict";var isEqualWith=require("lodash.isequalwith");class Matcher{}class EqualsMatcher extends Matcher{expected;constructor(expected){super(),this.expected=expected}matches(value){return isEqualWith(this.expected,value,((a,b)=>a instanceof Matcher?a.matches(b):a==b||void 0))}toString(){return`eq(${this.expected.toString()})`}}function eq(expected){return new EqualsMatcher(expected)}class AndMatcher extends Matcher{matchers;constructor(...matchers){super(),this.matchers=matchers}matches(value){return this.matchers.every((m=>m.matches(value)))}toString(){return`and(${this.matchers.map((m=>m.toString())).join(", ")})`}}class AnyArray extends Matcher{matches(value){return Array.isArray(value)}toString(){return"anyArray()"}}class AnyFunctionMatcher extends Matcher{matches(value){return"function"==typeof value}toString(){return"anyFunction()"}}class AnyMatcher extends Matcher{matches(value){return!0}toString(){return"any()"}}class AnyNumber extends Matcher{matches(value){const type=typeof value;return"number"===type||"object"===type&&null!=value&&!Array.isArray(value)&&"[object Number]"===Object.prototype.toString.call(value)}toString(){return"anyNumber()"}}class AnyObjectMatcher extends Matcher{matches(value){return"object"===typeof value&&null!=value&&!Array.isArray(value)}toString(){return"anyObject()"}}class AnyString extends Matcher{matches(value){const type=typeof value;return"string"===type||"object"===type&&null!=value&&!Array.isArray(value)&&"[object String]"===Object.prototype.toString.call(value)}toString(){return"anyString()"}}class ClassMatcher extends Matcher{expectedClass;constructor(expectedClass){super(),this.expectedClass=expectedClass}matches(value){return value instanceof this.expectedClass}toString(){return`ofClass(${this.expectedClass.constructor.toString()})`}}class IdenticalMatcher extends Matcher{expected;constructor(expected){super(),this.expected=expected}matches(value){return value===this.expected}toString(){return`is(${this.expected.toString()})`}}class IsNilMatcher extends Matcher{matches(value){return null==value}toString(){return"isNil()"}}class IsNullMatcher extends Matcher{matches(value){return null===value}toString(){return"isNull()"}}class LessMatcher extends Matcher{max;constructor(max){super(),this.max=max}matches(value){return value<=this.max}toString(){return`less(${this.max})`}}class MoreMatcher extends Matcher{min;constructor(min){super(),this.min=min}matches(value){return value>=this.min}toString(){return`more(${this.min})`}}class NotMatcher extends Matcher{inner;constructor(inner){super(),this.inner=inner}matches(value){return!this.inner.matches(value)}toString(){return`not(${this.inner.toString()})`}}function not(matcher){return new NotMatcher(matcher instanceof Matcher?matcher:new EqualsMatcher(matcher))}class NotNilMatcher extends Matcher{matches(value){return null!=value}toString(){return"notNil()"}}class NotNullMatcher extends Matcher{matches(value){return null!==value}toString(){return"notNull()"}}class OrMatcher extends Matcher{matchers;constructor(...matchers){super(),this.matchers=matchers}matches(value){return!!this.matchers.find((m=>m.matches(value)))}toString(){return`or(${this.matchers.map((m=>m.toString())).join(", ")})`}}class RangeMatcher extends Matcher{from;to;constructor(from,to){super(),this.from=from,this.to=to}matches(value){return value<=this.to&&value>=this.from}toString(){return`range(${this.from}, ${this.to})`}}class MethodStub{name;matchers;constructor(name,matchers){this.name=name,this.matchers=matchers}matches(args){return this.matchers.every(((matcher,i)=>matcher.matches(args[i])))}hasSameMatchers(other){return this.matchers.length==other.matchers.length&&this.matchers.every(((matcher,i)=>isEqualWith(matcher,other.matchers[i])))}}class ReturnValueMethodStub extends MethodStub{value;constructor(name,matchers,value){super(name,matchers),this.value=value}execute(args){return this.value}}class ThrowErrorMethodStub extends MethodStub{error;constructor(name,matchers,error){super(name,matchers),this.error=error}execute(args){throw this.error}}class ResolvePromiseMethodStub extends MethodStub{value;constructor(name,matchers,value){super(name,matchers),this.value=value}execute(args){return Promise.resolve(this.value)}}class RejectPromiseMethodStub extends MethodStub{error;constructor(name,matchers,error){super(name,matchers),this.error=error}execute(args){return Promise.reject(this.error)}}class CallFunctionMethodStub extends MethodStub{func;constructor(name,matchers,func){super(name,matchers),this.func=func}execute(args){return this.func(...args)}}class MethodStubBuilder extends Function{mock;methodName;matchers;addMethodStub;defineMockMethodStub;isFirstStub=!0;constructor(mock,methodName,matchers,addMethodStub,defineMockMethodStub){return super(),this.mock=mock,this.methodName=methodName,this.matchers=matchers,this.addMethodStub=addMethodStub,this.defineMockMethodStub=defineMockMethodStub,new Proxy(this,{apply:(target,thisArg,argArray)=>target.__call(...argArray)})}doAddMethodStub(stub){const appendAnswer=!this.isFirstStub;this.addMethodStub(stub,appendAnswer),this.isFirstStub=!1}returns(param=void 0,...rest){return this.doAddMethodStub(new ReturnValueMethodStub(this.methodName,this.matchers,param)),rest.forEach((value=>{this.doAddMethodStub(new ReturnValueMethodStub(this.methodName,this.matchers,value))})),this}throws(error=new Error("Some error")){return this.doAddMethodStub(new ThrowErrorMethodStub(this.methodName,this.matchers,error)),this}resolves(param=void 0,...rest){return this.doAddMethodStub(new ResolvePromiseMethodStub(this.methodName,this.matchers,param)),rest.forEach((value=>{this.doAddMethodStub(new ResolvePromiseMethodStub(this.methodName,this.matchers,value))})),this}rejects(error=new Error("Some error")){return this.doAddMethodStub(new RejectPromiseMethodStub(this.methodName,this.matchers,error)),this}calls(func){return this.doAddMethodStub(new CallFunctionMethodStub(this.methodName,this.matchers,func)),this}__call(...args){return this.defineMockMethodStub(this.methodName,!0),this.mock[this.methodName](...args)}}class MultipleInvocationsVerificator{invocationTracker;invocationsToVerify=[];proxy;constructor(invocationTracker){return this.invocationTracker=invocationTracker,this.proxy=new Proxy(this,{get:(target,name)=>name in target?target[name]:this.methodVerifier(name.toString())}),this.proxy}called(){this.failIfEmptyInvocationsToVerify();const failedInvocations=[];for(let invocationToVerify of this.invocationsToVerify){0===this.invocationTracker.getMatchingInvocations(invocationToVerify.name,invocationToVerify.matchers).length&&failedInvocations.push(invocationToVerify)}if(failedInvocations.length>0){const message="Expected calls:\n"+this.invocationsToVerify.map((m=>`- ${m.toString()}\n`)).join("")+"\nMissing calls:\n"+failedInvocations.map((m=>`- ${m.toString()}\n`)).join("");throw new Error(message+this.getAllCallsMessage())}}never(){this.failIfEmptyInvocationsToVerify();const failedInvocations=[];for(let invocationToVerify of this.invocationsToVerify){const invocations=this.invocationTracker.getMatchingInvocations(invocationToVerify.name,invocationToVerify.matchers);invocations.length>0&&failedInvocations.push(...invocations)}if(failedInvocations.length>0){const message="Expected to never be called:\n"+this.invocationsToVerify.map((m=>`- ${m.toString()}\n`)).join("")+"\nUnexpected calls:\n"+failedInvocations.map((m=>`- ${m.toString()}\n`)).join("");throw new Error(message+this.getAllCallsMessage())}}calledInOrder(){this.failIfEmptyInvocationsToVerify();let lastIndex=-1;for(let invocationToVerify of this.invocationsToVerify){const methodString=`${invocationToVerify.name}(${invocationToVerify.matchers.map((m=>m.toString())).join(", ")})`;let invocations=this.invocationTracker.getMatchingInvocations(invocationToVerify.name,invocationToVerify.matchers);if(0===invocations.length){throw new Error(`Expected "${methodString}" to be called but was never called.\n`+this.getAllCallsMessage())}if(invocations=invocations.filter((it=>it.index>lastIndex)),0===invocations.length){throw new Error(`Expected "${methodString}" to be called in the specified order.\n`+this.getAllCallsMessage())}lastIndex=invocations[0].index}}failIfEmptyInvocationsToVerify(){if(0===this.invocationsToVerify.length)throw new Error("Must specify at least one method or property to verify")}getAllCallsMessage(){const invocations=this.invocationTracker.getAllInvocations();return 0===invocations.length?"":"\nAll calls:\n"+invocations.map((m=>`- ${m.toString()}\n`)).join("")}methodVerifier(name){return(...args)=>{const matchers=args.map((it=>it instanceof Matcher?it:eq(it)));return this.invocationsToVerify.push(new InvocationToVerify(name,matchers)),this.proxy}}}class InvocationToVerify{name;matchers;constructor(name,matchers){this.name=name,this.matchers=matchers}toString(){return`${this.name}(${this.matchers.map((a=>a.toString())).join(", ")})`}}let globalIndex=0;class Invocation{index;name;args;globalIndex=globalIndex++;constructor(index,name,args){this.index=index,this.name=name,this.args=args}matches(matchers){return matchers.every(((matcher,i)=>matcher.matches(this.args[i])))}toString(){return`${this.name}(${this.args.map((a=>a.toString())).join(", ")})`}}class InvocationTracker{invocations=[];add(name,args){this.invocations.push(new Invocation(this.invocations.length,name,args))}getMatchingInvocations(name,matchers){return this.invocations.filter((invocation=>invocation.name===name&&invocation.matches(matchers)))}getInvocationsByName(name){return this.invocations.filter((invocation=>invocation.name===name))}getAllInvocations(){return this.invocations}reset(){this.invocations=[]}}function isObject(value){const type=typeof value;return null!=value&&("object"===type||"function"===type)}class ObjectInspector{excludedPropertyNames=["hasOwnProperty"];getPrototypes(object){const prototypes=[];let current=object;for(;isObject(current)&¤t!==Object.prototype&¤t!==Function.prototype;)prototypes.push(current),current=Object.getPrototypeOf(current);return prototypes}getOwnPropertyNames(object){return isObject(object)?Object.getOwnPropertyNames(object):[]}getAllPropertyNames(object){const names=[];return this.getPrototypes(object).forEach((obj=>{this.getOwnPropertyNames(obj).forEach((propertyName=>{this.propertyIsExcluded(propertyName)||names.push({obj:obj,propertyName:propertyName})}))})),names}propertyIsExcluded(propertyName){return this.excludedPropertyNames.indexOf(propertyName)>=0}}class Spy{invocationTracker=new InvocationTracker;inspector=new ObjectInspector;originalProperties={};constructor(instance){this.spy(instance)}spy(instance){for(const{propertyName:propertyName}of this.inspector.getAllPropertyNames(instance)){if("constructor"===propertyName)continue;const property=instance[propertyName];this.originalProperties[propertyName]=property,"function"==typeof property?instance[propertyName]=this.spyFunction(propertyName):this.spyProperty(instance,propertyName)}}spyFunction(name){return(...args)=>(this.invocationTracker.add(name,args),this.originalProperties[name](...args))}spyProperty(instance,propertyName){Object.defineProperty(instance,propertyName,{get:()=>(this.invocationTracker.add("getProperty",[propertyName]),this.originalProperties[propertyName]),set:newValue=>{this.invocationTracker.add("setProperty",[propertyName,newValue]),this.originalProperties[propertyName]=newValue}})}}function getInvocationTracker(instance){if(instance.__mocktMocker)return instance.__mocktMocker.invocationTracker;if(instance instanceof Spy)return instance.invocationTracker;throw new Error("Given instance is not a mock nor a spy")}function captureLast(instance){return createCaptureProxy(instance,(invocations=>invocations[invocations.length-1].args))}function createCaptureProxy(instance,returnFunc){const invocationTracker=getInvocationTracker(instance);return new Proxy({},{get(target,property){const propertyName=property.toString();if("setProperty"===propertyName)return name=>{const allInvocations=invocationTracker.getInvocationsByName(propertyName).filter((it=>it.args[0]===name));return 0===allInvocations.length?[]:returnFunc(allInvocations.map((it=>new Invocation(it.index,it.name,[it.args[1]]))))};const allInvocations=invocationTracker.getInvocationsByName(propertyName);return 0===allInvocations.length?[]:returnFunc(allInvocations)}})}class NullMethodStub extends MethodStub{constructor(name){super(name,[])}matches(args){return!0}execute(args){}}class UnknownResponse extends Function{constructor(propertyName,invocationTracker){super();const nonTrackingProxy=new Proxy(this,{apply:(target,thisArg,argArray)=>nonTrackingProxy});return new Proxy(nonTrackingProxy,{apply:(target,thisArg,argArray)=>(invocationTracker.add(propertyName,argArray),nonTrackingProxy)})}}class MultiAnswerMethodStub extends MethodStub{answers;answerIndex=0;constructor(name,matchers,answer){super(name,matchers),this.answers=[answer]}execute(args){const currentIndex=this.answerIndex;return this.answerIndex=Math.min(this.answerIndex+1,this.answers.length-1),this.answers[currentIndex].execute(args)}append(answer){this.answers.push(answer)}reset(){this.answerIndex=0}static from(answer){return new MultiAnswerMethodStub(answer.name,answer.matchers,answer)}}class Mocker{clazz;internalMock={};mock;instance={};objectInspector=new ObjectInspector;methodStubs={};invocationTracker=new InvocationTracker;mocktProperty="__mocktMocker";constructor(clazz){this.clazz=clazz,this.mock=this.createMock(),this.addMockClassStubs(),this.instance=this.createInstance()}createInstance(){const instance=new Proxy(this.instance,{get:(target,name)=>{if(name in target)return target[name];let propertyName=name.toString();return this.invocationTracker.add("getProperty",[propertyName]),new UnknownResponse(propertyName,this.invocationTracker)},set:(target,name,newValue)=>(name!==this.mocktProperty&&this.invocationTracker.add("setProperty",[name,newValue]),target[name]=newValue,!0)});return instance[this.mocktProperty]=this,instance}createMock(){const mock=new Proxy(this.internalMock,{get:(target,name)=>(name in target||this.defineMockPropertyStub(name.toString()),target[name])});return mock[this.mocktProperty]=this,mock}addMockClassStubs(){isObject(this.clazz)&&this.objectInspector.getAllPropertyNames(this.clazz.prototype).forEach((({obj:obj,propertyName:propertyName})=>{const descriptor=Object.getOwnPropertyDescriptor(obj,propertyName);descriptor.get?this.defineMockPropertyStub(propertyName):"function"==typeof descriptor.value&&this.defineMockMethodStub(propertyName)}))}defineMockPropertyStub(propertyName,force=!1){force&&delete this.internalMock[propertyName],Object.hasOwn(this.internalMock,propertyName)||propertyName===this.mocktProperty||(Object.defineProperty(this.internalMock,propertyName,{get:this.createMethodStub(propertyName),configurable:!0}),this.defineInstancePropertyExecutor(propertyName,force))}defineMockMethodStub(methodName,force=!1){force&&delete this.internalMock[methodName],Object.hasOwn(this.internalMock,methodName)||(this.internalMock[methodName]=this.createMethodStub(methodName),this.defineInstanceMethodExecutor(methodName,force))}createMethodStub(name){return(...args)=>{const matchers=args.map((it=>it instanceof Matcher?it:eq(it)));return new MethodStubBuilder(this.internalMock,name,matchers,this.addMethodStub.bind(this),this.defineMockMethodStub.bind(this))}}addMethodStub(stub,appendAnswer=!1){if(this.methodStubs[stub.name]||(this.methodStubs[stub.name]=[]),appendAnswer){const existingStub=this.methodStubs[stub.name].findLast((it=>it.hasSameMatchers(stub)));if(existingStub)return void existingStub.append(stub)}this.methodStubs[stub.name].push(MultiAnswerMethodStub.from(stub))}defineInstancePropertyExecutor(propertyName,force=!1){force&&delete this.instance[propertyName],Object.hasOwn(this.instance,propertyName)||propertyName===this.mocktProperty||Object.defineProperty(this.instance,propertyName,{get:()=>{this.invocationTracker.add("getProperty",[propertyName]);return this.findMethodStub(propertyName,[]).execute([])},set:value=>{this.invocationTracker.add("setProperty",[propertyName,value])},configurable:!0})}defineInstanceMethodExecutor(methodName,force=!1){force&&delete this.instance[methodName],Object.hasOwn(this.instance,methodName)||(this.instance[methodName]=(...args)=>{this.invocationTracker.add(methodName,args);return this.findMethodStub(methodName,args).execute(args)})}findMethodStub(name,args){if(this.methodStubs[name]){const stub=this.methodStubs[name].findLast((stub=>stub.matches(args)));if(stub)return stub}return new NullMethodStub(name)}resetCalls(){for(let methodName of Object.keys(this.methodStubs))this.methodStubs[methodName].forEach((stub=>stub.reset()));this.invocationTracker.reset()}reset(){this.methodStubs={},this.invocationTracker.reset()}}class SimpleInvocationVerificator{invocationTracker;verifier;constructor(invocationTracker,verifier){return this.invocationTracker=invocationTracker,this.verifier=verifier,new Proxy(this,{get:(target,name)=>this.methodVerifier(name.toString())})}methodVerifier(name){return(...args)=>{const matchers=args.map((it=>it instanceof Matcher?it:eq(it))),invocations=this.invocationTracker.getMatchingInvocations(name,matchers);this.verifier.verify(this.invocationTracker,name,matchers,invocations)}}}class SimpleInvocationVerifier{verify(invocationTracker,methodName,matchers,invocations){if(this.isValid(invocations))return;const methodString=`${methodName}(${matchers.map((m=>m.toString())).join(", ")})`;throw new Error(this.getErrorMessage(methodString,invocations)+this.getActualCallsMessage(invocationTracker,methodName))}getActualCallsMessage(invocationTracker,methodName){const invocations=invocationTracker.getInvocationsByName(methodName);return 0===invocations.length?"":"\n\nActual calls:\n"+invocations.map((m=>`- ${m.toString()}\n`)).join("")}}class AtLeastOnceVerifier extends SimpleInvocationVerifier{isValid(invocations){return invocations.length>0}getErrorMessage(methodString,matchedCalls){return`Expected "${methodString}" to be called but has never been called.`}}class OnceVerifier extends SimpleInvocationVerifier{isValid(invocations){return 1===invocations.length}getErrorMessage(methodString,matchedCalls){return`Expected "${methodString}" to be called once but has been called ${matchedCalls.length} time(s).`}}class NeverVerifier extends SimpleInvocationVerifier{isValid(invocations){return 0===invocations.length}getErrorMessage(methodString,matchedCalls){return`Expected "${methodString}" to never been called but has been called ${matchedCalls.length} time(s).`}}class TimesVerifier extends SimpleInvocationVerifier{times;constructor(times){super(),this.times=times}isValid(invocations){return invocations.length===this.times}getErrorMessage(methodString,matchedCalls){return`Expected "${methodString}" to been called ${this.times} time(s) but has been called ${matchedCalls.length} time(s).`}}class AtLeastVerifier extends SimpleInvocationVerifier{times;constructor(times){super(),this.times=times}isValid(invocations){return invocations.length>=this.times}getErrorMessage(methodString,matchedCalls){return`Expected "${methodString}" to been called at least ${this.times} time(s) but has been called ${matchedCalls.length} time(s).`}}class AtMostVerifier extends SimpleInvocationVerifier{times;constructor(times){super(),this.times=times}isValid(invocations){return invocations.length<=this.times}getErrorMessage(methodString,matchedCalls){return`Expected "${methodString}" to been called at most ${this.times} time(s) but has been called ${matchedCalls.length} time(s).`}}class SequenceVerificator{lastGlobalCallIndex=-1;call(instance){const invocationTracker=getInvocationTracker(instance);return new Proxy({},{get:(target,name)=>{const propertyName=name.toString();return(...args)=>{const matchers=args.map((it=>it instanceof Matcher?it:eq(it))),methodString=`${propertyName}(${matchers.map((m=>m.toString())).join(", ")})`;let invocations=invocationTracker.getMatchingInvocations(propertyName,matchers);if(0===invocations.length)throw new Error(`Expected "${methodString}" to be called but has never been called.\n`);if(invocations=invocations.filter((it=>it.globalIndex>this.lastGlobalCallIndex)),0===invocations.length)throw new Error(`Expected "${methodString}" to be called in the specified order.\n`);return this.lastGlobalCallIndex=invocations[0].globalIndex,this}}})}}exports.AndMatcher=AndMatcher,exports.AnyArray=AnyArray,exports.AnyFunctionMatcher=AnyFunctionMatcher,exports.AnyMatcher=AnyMatcher,exports.AnyNumber=AnyNumber,exports.AnyObjectMatcher=AnyObjectMatcher,exports.AnyString=AnyString,exports.ClassMatcher=ClassMatcher,exports.EqualsMatcher=EqualsMatcher,exports.IdenticalMatcher=IdenticalMatcher,exports.IsNilMatcher=IsNilMatcher,exports.IsNullMatcher=IsNullMatcher,exports.LessMatcher=LessMatcher,exports.Matcher=Matcher,exports.MethodStubBuilder=MethodStubBuilder,exports.MoreMatcher=MoreMatcher,exports.MultipleInvocationsVerificator=MultipleInvocationsVerificator,exports.NotMatcher=NotMatcher,exports.NotNilMatcher=NotNilMatcher,exports.NotNullMatcher=NotNullMatcher,exports.OrMatcher=OrMatcher,exports.RangeMatcher=RangeMatcher,exports.UnknownResponse=UnknownResponse,exports.and=function(...matchers){const resolvedMatchers=matchers.map((m=>m instanceof Matcher?m:new EqualsMatcher(m)));return new AndMatcher(...resolvedMatchers)},exports.any=function(){return new AnyMatcher},exports.anyArray=function(){return new AnyArray},exports.anyFunction=function(){return new AnyFunctionMatcher},exports.anyNumber=function(){return new AnyNumber},exports.anyObject=function(){return new AnyObjectMatcher},exports.anyString=function(){return new AnyString},exports.capture=function(instance){return captureLast(instance)},exports.captureAll=function(instance){return createCaptureProxy(instance,(invocations=>invocations.map((it=>it.args))))},exports.captureFirst=function(instance){return createCaptureProxy(instance,(invocations=>invocations[0].args))},exports.captureLast=captureLast,exports.eq=eq,exports.is=function(expected){return new IdenticalMatcher(expected)},exports.isNil=function(){return new IsNilMatcher},exports.isNull=function(){return new IsNullMatcher},exports.less=function(max){return new LessMatcher(max)},exports.mockt=function(clazz){return new Mocker(clazz).instance},exports.more=function(min){return new MoreMatcher(min)},exports.neq=function(expected){return not(new EqualsMatcher(expected))},exports.not=not,exports.notNil=function(){return new NotNilMatcher},exports.notNull=function(){return new NotNullMatcher},exports.ofClass=function(expectedClass){return new ClassMatcher(expectedClass)},exports.or=function(...matchers){const resolvedMatchers=matchers.map((m=>m instanceof Matcher?m:new EqualsMatcher(m)));return new OrMatcher(...resolvedMatchers)},exports.range=function(from,to){return new RangeMatcher(from,to)},exports.reset=function(...instances){instances.forEach((instance=>{const mocker=instance.__mocktMocker;if(!mocker)throw new Error("Given instance is not a mock");mocker.reset()}))},exports.resetCalls=function(...instances){instances.forEach((instance=>{const mocker=instance.__mocktMocker;if(!mocker)throw new Error("Given instance is not a mock");mocker.resetCalls()}))},exports.spy=function(instance){return new Spy(instance)},exports.verify=function(instance){return new SimpleInvocationVerificator(getInvocationTracker(instance),new AtLeastOnceVerifier)},exports.verifyAtLeast=function(times,instance){return new SimpleInvocationVerificator(getInvocationTracker(instance),new AtLeastVerifier(times))},exports.verifyAtMost=function(times,instance){return new SimpleInvocationVerificator(getInvocationTracker(instance),new AtMostVerifier(times))},exports.verifyMulti=function(instance){return new MultipleInvocationsVerificator(getInvocationTracker(instance))},exports.verifyNever=function(instance){return new SimpleInvocationVerificator(getInvocationTracker(instance),new NeverVerifier)},exports.verifyOnce=function(instance){return new SimpleInvocationVerificator(getInvocationTracker(instance),new OnceVerifier)},exports.verifySequence=function(){return new SequenceVerificator},exports.verifyTimes=function(times,instance){return new SimpleInvocationVerificator(getInvocationTracker(instance),new TimesVerifier(times))},exports.when=function(instance){const mocker=instance.__mocktMocker;if(!mocker)throw new Error("Given instance is not a mock");return mocker.mock};
//# sourceMappingURL=index.js.map