@johanblumenberg/ts-mockito
Advanced tools
Comparing version 1.0.13 to 1.0.14
@@ -9,5 +9,5 @@ import { MethodToStub } from "./MethodToStub"; | ||
thenThrow(...rest: Error[]): this; | ||
thenCall(func: (...args: any[]) => any): this; | ||
thenCall(func: (...args: any[]) => T): this; | ||
thenResolve(...rest: ResolveType[]): this; | ||
thenReject(...rest: RejectType[]): this; | ||
} |
@@ -5,2 +5,3 @@ import { MethodToStub } from "./MethodToStub"; | ||
private methodCallToStringConverter; | ||
private actualCalls; | ||
constructor(methodToVerify: MethodToStub); | ||
@@ -7,0 +8,0 @@ called(): void; |
@@ -11,2 +11,6 @@ "use strict"; | ||
} | ||
MethodStubVerificator.prototype.actualCalls = function () { | ||
var calls = this.methodToVerify.mocker.getActionsByName(this.methodToVerify.methodName); | ||
return 'Actual calls:\n ' + this.methodCallToStringConverter.convertActualCalls(calls).join('\n '); | ||
}; | ||
MethodStubVerificator.prototype.called = function () { | ||
@@ -31,3 +35,4 @@ this.atLeast(1); | ||
var methodToVerifyAsString = this.methodCallToStringConverter.convert(this.methodToVerify); | ||
throw new Error("Expected \"" + methodToVerifyAsString + "to be called " + value + " time(s). But has been called " + allMatchingActions.length + " time(s)."); | ||
var msg = "Expected \"" + methodToVerifyAsString + "to be called " + value + " time(s). But has been called " + allMatchingActions.length + " time(s)."; | ||
throw new Error(msg + '\n' + this.actualCalls()); | ||
} | ||
@@ -39,3 +44,4 @@ }; | ||
var methodToVerifyAsString = this.methodCallToStringConverter.convert(this.methodToVerify); | ||
throw new Error("Expected \"" + methodToVerifyAsString + "to be called at least " + value + " time(s). But has been called " + allMatchingActions.length + " time(s)."); | ||
var msg = "Expected \"" + methodToVerifyAsString + "to be called at least " + value + " time(s). But has been called " + allMatchingActions.length + " time(s)."; | ||
throw new Error(msg + '\n' + this.actualCalls()); | ||
} | ||
@@ -47,3 +53,4 @@ }; | ||
var methodToVerifyAsString = this.methodCallToStringConverter.convert(this.methodToVerify); | ||
throw new Error("Expected \"" + methodToVerifyAsString + "to be called at least " + value + " time(s). But has been called " + allMatchingActions.length + " time(s)."); | ||
var msg = "Expected \"" + methodToVerifyAsString + "to be called at most " + value + " time(s). But has been called " + allMatchingActions.length + " time(s)."; | ||
throw new Error(msg + '\n' + this.actualCalls()); | ||
} | ||
@@ -50,0 +57,0 @@ }; |
@@ -29,3 +29,3 @@ import { ArgCaptor1, ArgCaptor10, ArgCaptor2, ArgCaptor3, ArgCaptor4, ArgCaptor5, ArgCaptor6, ArgCaptor7, ArgCaptor8, ArgCaptor9 } from "./capture/ArgCaptor"; | ||
export declare function anyOfClass<T>(expectedClass: new (...args: any[]) => T): any; | ||
export declare function anyFunction(): any; | ||
export declare function anyFunction<T>(): () => T; | ||
export declare function anyNumber(): number; | ||
@@ -32,0 +32,0 @@ export declare function anyString(): string; |
@@ -163,3 +163,3 @@ "use strict"; | ||
function nextTick() { | ||
return new Promise(function (resolve) { return setImmediate(resolve); }); | ||
return new Promise(function (resolve) { return setTimeout(function () { return setImmediate(resolve); }, 0); }); | ||
} | ||
@@ -166,0 +166,0 @@ exports.nextTick = nextTick; |
import { MethodToStub } from "../MethodToStub"; | ||
import { MethodAction } from "../MethodAction"; | ||
export declare class MethodCallToStringConverter { | ||
convert(method: MethodToStub): string; | ||
convertActualCalls(calls: MethodAction[]): string[]; | ||
} |
@@ -11,2 +11,5 @@ "use strict"; | ||
}; | ||
MethodCallToStringConverter.prototype.convertActualCalls = function (calls) { | ||
return calls.map(function (call) { return call.methodName + '(' + call.args.map(function (arg) { return arg.toString(); }).join(', ') + ')'; }); | ||
}; | ||
return MethodCallToStringConverter; | ||
@@ -13,0 +16,0 @@ }()); |
{ | ||
"name": "@johanblumenberg/ts-mockito", | ||
"version": "1.0.13", | ||
"version": "1.0.14", | ||
"description": "Mocking library for TypeScript", | ||
@@ -5,0 +5,0 @@ "main": "lib/ts-mockito.js", |
@@ -11,2 +11,5 @@ # @johanblumenberg/ts-mockito | ||
- [Support enumerating properties on mocks](https://github.com/johanblumenberg/ts-mockito/commit/67195b7317014b6da27b97869efaeb6305d739da) | ||
- [Adding `nextTick()`](https://github.com/johanblumenberg/ts-mockito/pull/2) | ||
- [Better types on `anyFunction()` and `thenCall()`](https://github.com/johanblumenberg/ts-mockito/pull/3) | ||
- [Better call verification error messages](https://github.com/johanblumenberg/ts-mockito/pull/4) | ||
@@ -13,0 +16,0 @@ ## Installation |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
435
145991
115
2142