@johanblumenberg/ts-mockito
Advanced tools
Comparing version 1.0.34 to 1.0.35
import { MethodToStub } from "./MethodToStub"; | ||
export interface SyncMethodStubSetter<T> { | ||
thenReturn(...rest: T[]): this; | ||
thenThrow(...rest: Error[]): this; | ||
thenReturn(head: T, ...tail: T[]): this; | ||
thenThrow(head: Error, ...tail: Error[]): this; | ||
thenCall(func: (...args: any[]) => T): this; | ||
} | ||
export interface VoidSyncMethodStubSetter<T> { | ||
thenReturn(head: T, ...tail: T[]): this; | ||
thenReturn(): this; | ||
thenThrow(head: Error, ...tail: Error[]): this; | ||
thenCall(func: (...args: any[]) => T): this; | ||
} | ||
export interface AsyncMethodStubSetter<T, ResolveType> extends SyncMethodStubSetter<T> { | ||
thenResolve(...rest: ResolveType[]): this; | ||
thenReject(...rest: any[]): this; | ||
thenResolve(head: ResolveType, ...tail: ResolveType[]): this; | ||
thenReject(head: any, ...tail: any[]): this; | ||
} | ||
export declare class MethodStubSetter<T, ResolveType> implements AsyncMethodStubSetter<T, ResolveType> { | ||
export interface VoidAsyncMethodStubSetter<T, ResolveType> extends VoidSyncMethodStubSetter<T> { | ||
thenResolve(head: ResolveType, ...tail: ResolveType[]): this; | ||
thenResolve(): this; | ||
thenReject(head: any, ...tail: any[]): this; | ||
} | ||
export declare class MethodStubSetter<T, ResolveType> implements AsyncMethodStubSetter<T, ResolveType>, VoidAsyncMethodStubSetter<T, ResolveType> { | ||
private methodToStub; | ||
@@ -13,0 +24,0 @@ private static globalGroupIndex; |
@@ -21,2 +21,5 @@ "use strict"; | ||
} | ||
if (rest.length === 0) { | ||
rest.push(undefined); | ||
} | ||
rest.forEach(function (value) { | ||
@@ -23,0 +26,0 @@ _this.methodToStub.methodStubCollection.add(new ReturnValueMethodStub_1.ReturnValueMethodStub(_this.groupIndex, _this.methodToStub.matchers, value)); |
import { ArgCaptor1, ArgCaptor10, ArgCaptor2, ArgCaptor3, ArgCaptor4, ArgCaptor5, ArgCaptor6, ArgCaptor7, ArgCaptor8, ArgCaptor9 } from "./capture/ArgCaptor"; | ||
import { MaybeDate } from "./matcher/type/date/DateMatcher"; | ||
import { AsyncMethodStubSetter, SyncMethodStubSetter } from "./MethodStubSetter"; | ||
import { AsyncMethodStubSetter, VoidAsyncMethodStubSetter, SyncMethodStubSetter, VoidSyncMethodStubSetter } from "./MethodStubSetter"; | ||
import { MethodStubVerificator } from "./MethodStubVerificator"; | ||
@@ -15,4 +15,6 @@ import { MockPropertyPolicy } from "./Mock"; | ||
export declare function verify<T>(method: T): MethodStubVerificator<T>; | ||
export declare function when<T>(method: PromiseLike<void>): VoidAsyncMethodStubSetter<PromiseLike<T>, T>; | ||
export declare function when<T>(method: PromiseLike<T>): AsyncMethodStubSetter<PromiseLike<T>, T>; | ||
export declare function when<T>(method: Promise<T>): AsyncMethodStubSetter<Promise<T>, T>; | ||
export declare function when<T>(method: void): VoidSyncMethodStubSetter<T>; | ||
export declare function when<T>(method: T): 0 extends (1 & T) ? AsyncMethodStubSetter<any, any> : SyncMethodStubSetter<T>; | ||
@@ -19,0 +21,0 @@ export declare function instance<T>(mockedValue: T): T; |
{ | ||
"name": "@johanblumenberg/ts-mockito", | ||
"version": "1.0.34", | ||
"version": "1.0.35", | ||
"description": "Mocking library for TypeScript", | ||
@@ -48,3 +48,2 @@ "main": "lib/ts-mockito.js", | ||
"karma-typescript-preprocessor": "^0.4.0", | ||
"puppeteer": "^5.5.0", | ||
"ts-expect": "^1.3.0", | ||
@@ -51,0 +50,0 @@ "ts-helpers": "^1.1.2", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
179539
19
2715