UNPKG

@johanblumenberg/ts-mockito

Version:
117 lines (116 loc) 6.85 kB
import { ArgCaptor } from "./capture/ArgCaptor"; import { MaybeDate } from "./matcher/type/date/DateMatcher"; import { AsyncMethodStubSetter, VoidAsyncMethodStubSetter, SyncMethodStubSetter, VoidSyncMethodStubSetter } from "./MethodStubSetter"; import { MethodStubVerificator } from "./MethodStubVerificator"; import { MockPropertyPolicy, MockOptions } from "./Mock"; import { Matcher } from './matcher/type/Matcher'; export { MockPropertyPolicy, MockOptions } from "./Mock"; export declare function spy<T>(instanceToSpy: T): T; export declare function mock<T>(clazz: (new (...args: any[]) => T) | (Function & { prototype: T; }), policy?: MockPropertyPolicy): T; export declare function imock<T>(policy?: MockPropertyPolicy): NonNullable<T> extends object ? T : unknown; export declare function imock<T>(options?: MockOptions): NonNullable<T> extends object ? T : unknown; export declare function fnmock<T extends (...args: any[]) => void>(): T; export declare function cmock<R, T extends any[]>(): new (...args: T) => R; 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>; export declare function instance<T>(mockedValue: T): T; export declare function capture<T extends any[]>(method: (...args: T) => any): ArgCaptor<T>; export declare function capture<T extends any[], M extends T = T>(method: (...args: T) => any, matchers: M): ArgCaptor<T>; export declare function capture<T0>(method: (a: T0) => any): ArgCaptor<[T0]>; export declare function capture<T0, T1>(method: (a: T0, b: T1) => any): ArgCaptor<[T0, T1]>; export declare function capture<T0, T1, T2>(method: (a: T0, b: T1, c: T2) => any): ArgCaptor<[T0, T1, T2]>; export declare function capture<T0, T1, T2, T3>(method: (a: T0, b: T1, c: T2, d: T3) => any): ArgCaptor<[T0, T1, T2, T3]>; export declare function capture<T0, T1, T2, T3, T4>(method: (a: T0, b: T1, c: T2, d: T3, e: T4) => any): ArgCaptor<[T0, T1, T2, T3, T4]>; export declare function capture<T0, T1, T2, T3, T4, T5>(method: (a: T0, b: T1, c: T2, d: T3, e: T4, f: T5) => any): ArgCaptor<[T0, T1, T2, T3, T4, T5]>; export declare function capture<T0, T1, T2, T3, T4, T5, T6>(method: (a: T0, b: T1, c: T2, d: T3, e: T4, f: T5, g: T6) => any): ArgCaptor<[T0, T1, T2, T3, T4, T5, T6]>; export declare function capture<T0, T1, T2, T3, T4, T5, T6, T7>(method: (a: T0, b: T1, c: T2, d: T3, e: T4, f: T5, g: T6, h: T7) => any): ArgCaptor<[T0, T1, T2, T3, T4, T5, T6, T7]>; export declare function capture<T0, T1, T2, T3, T4, T5, T6, T7, T8>(method: (a: T0, b: T1, c: T2, d: T3, e: T4, f: T5, g: T6, h: T7, i: T8) => any): ArgCaptor<[T0, T1, T2, T3, T4, T5, T6, T7, T8]>; export declare function capture<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>(method: (a: T0, b: T1, c: T2, d: T3, e: T4, f: T5, g: T6, h: T7, i: T8, j: T9) => any): ArgCaptor<[T0, T1, T2, T3, T4, T5, T6, T7, T8, T9]>; export declare function reset<T>(mockedValue: T): void; export declare function resetStubs<T>(mockedValue: T): void; export declare function resetCalls<T>(mockedValue: T): void; export { Matcher } from './matcher/type/Matcher'; export declare function anyOfClass<T>(expectedClass: new (...args: any[]) => T): any; export declare function anyFunction<T>(): () => T; export declare function anyNumber(): number; export declare function anyString(): string; export declare function anything(): any; export declare const _: any; export declare function not<T>(expectedValue: T): T; export declare function between(min: number, max: number): number; export declare function deepEqual<T>(expectedValue: T): T; export declare function notNull(): any; export declare function strictEqual<T>(expectedValue: T): T; export declare function match(expectedValue: RegExp | string): string; export declare function startsWith(expectedValue: string): string; export declare function endsWith(expectedValue: string): string; declare type RecursivePartial<T> = { [P in keyof T]?: T[P] extends (infer U)[] ? RecursivePartial<U>[] : T[P] extends object ? RecursivePartial<T[P]> : T[P]; }; export declare function arrayContaining<T>(expectedValue: T): T[]; export declare function objectContaining<T>(expectedValue: RecursivePartial<T extends true ? T : T>): T; export declare function jsonContaining<T>(expectedValue: T): string; export declare type Deferred<T> = Promise<T> & { resolve: (value: T) => Promise<void>; reject: (err: any) => Promise<void>; }; export declare function defer<T>(): Deferred<T>; export declare function nextTick(): Promise<void>; export declare function isAfter(date: MaybeDate): Date; export declare function isAfterOrEqual(date: MaybeDate): Date; export declare function isBefore(date: MaybeDate): Date; export declare function isBeforeOrEqual(date: MaybeDate): Date; export declare function greaterThan(value: number): number; export declare function greaterThanOrEqual(value: number): number; export declare function lowerThan(value: number): number; export declare function lowerThanOrEqual(value: number): number; declare const _default: { spy: typeof spy; mock: typeof mock; imock: typeof imock; fnmock: typeof fnmock; cmock: typeof cmock; verify: typeof verify; when: typeof when; instance: typeof instance; capture: typeof capture; reset: typeof reset; resetStubs: typeof resetStubs; resetCalls: typeof resetCalls; Matcher: typeof Matcher; anyOfClass: typeof anyOfClass; anyFunction: typeof anyFunction; anyNumber: typeof anyNumber; anyString: typeof anyString; anything: typeof anything; _: any; between: typeof between; deepEqual: typeof deepEqual; not: typeof not; notNull: typeof notNull; strictEqual: typeof strictEqual; match: typeof match; startsWith: typeof startsWith; endsWith: typeof endsWith; arrayContaining: typeof arrayContaining; objectContaining: typeof objectContaining; jsonContaining: typeof jsonContaining; MockPropertyPolicy: typeof MockPropertyPolicy; defer: typeof defer; nextTick: typeof nextTick; isAfter: typeof isAfter; isAfterOrEqual: typeof isAfterOrEqual; isBefore: typeof isBefore; isBeforeOrEqual: typeof isBeforeOrEqual; greaterThan: typeof greaterThan; greaterThanOrEqual: typeof greaterThanOrEqual; lowerThan: typeof lowerThan; lowerThanOrEqual: typeof lowerThanOrEqual; }; export default _default;