mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
Merge pull request #13779 from merrywhether/expect
Update types for expect v1.20.2
This commit is contained in:
+798
-391
File diff suppressed because it is too large
Load Diff
Vendored
+76
-49
@@ -1,72 +1,99 @@
|
||||
// Type definitions for Expect v1.13.4
|
||||
// Type definitions for Expect 1.20
|
||||
// Project: https://github.com/mjackson/expect
|
||||
// Definitions by: Justin Reidy <https://github.com/jmreidy/>
|
||||
// Definitions by: Justin Reidy <https://github.com/jmreidy/>, Risto Keravuori <https://github.com/merrywhether/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace expect {
|
||||
export class Expectation {
|
||||
export type CompareValues<T> = (a: T, b: T) => boolean;
|
||||
export type Comparator = (target: {}, key: string) => boolean;
|
||||
export type KeyType = string | number;
|
||||
|
||||
export class Expectation<T> {
|
||||
constructor(actual: any);
|
||||
toExist(message?: string): Expectation;
|
||||
toBeTruthy(message?: string): Expectation;
|
||||
toNotExist(message?: string): Expectation;
|
||||
toBeFalsy(message?: string): Expectation;
|
||||
toBe(value: any, message?: string): Expectation;
|
||||
toNotBe(value: any, message?: string): Expectation;
|
||||
toEqual(value: any, message?: string): Expectation;
|
||||
toNotEqual(value: any, message?: string): Expectation;
|
||||
toThrow(value?: any, message?: string): Expectation;
|
||||
toNotThrow(value?: any, message?: string): Expectation;
|
||||
toBeA(value: any, message?: string): Expectation;
|
||||
toBeAn(value: any, message?: string): Expectation;
|
||||
toNotBeA(value: any, message?: string): Expectation;
|
||||
toNotBeAn(value: any, message?: string): Expectation;
|
||||
toMatch(value: any, message?: string): Expectation;
|
||||
toNotMatch(value: any, message?: string): Expectation;
|
||||
toBeLessThan(value: any, message?: string): Expectation;
|
||||
toBeFewerThan(value: any, message?: string): Expectation;
|
||||
toBeGreaterThan(value: any, message?: string): Expectation;
|
||||
toBeMoreThan(value: any, message?: string): Expectation;
|
||||
toInclude(value: any, compareValues?: any, message?: string): Expectation;
|
||||
toContain(value: any, compareValues?: any, message?: string): Expectation;
|
||||
toExclude(value: any, compareValues?: any, message?: string): Expectation;
|
||||
toNotContain(value: any, compareValues?: any, message?: string): Expectation;
|
||||
toHaveBeenCalled(message?: string): Expectation;
|
||||
toHaveBeenCalledWith(...args: Array<any>): Expectation;
|
||||
toNotHaveBeenCalled(message?: string): Expectation;
|
||||
withContext(context: any): Expectation;
|
||||
withArgs(...args: Array<any>): Expectation;
|
||||
toExist(message?: string): Expectation<T>;
|
||||
toBeTruthy(message?: string): Expectation<T>;
|
||||
toNotExist(message?: string): Expectation<T>;
|
||||
toBeFalsy(message?: string): Expectation<T>;
|
||||
|
||||
toBe(value: T, message?: string): Expectation<T>;
|
||||
toNotBe(value: any, message?: string): Expectation<T>;
|
||||
toEqual(value: any, message?: string): Expectation<T>;
|
||||
toNotEqual(value: any, message?: string): Expectation<T>;
|
||||
toThrow(error?: {}, message?: string): Expectation<T>;
|
||||
toNotThrow(error?: {}, message?: string): Expectation<T>;
|
||||
|
||||
toBeA(value: string | {}, message?: string): Expectation<T>;
|
||||
toBeAn(value: string | {}, message?: string): Expectation<T>;
|
||||
toNotBeA(value: string | {}, message?: string): Expectation<T>;
|
||||
toNotBeAn(value: string | {}, message?: string): Expectation<T>;
|
||||
toMatch(value: string | RegExp | {}, message?: string): Expectation<T>;
|
||||
toNotMatch(value: string | RegExp | {}, message?: string): Expectation<T>;
|
||||
|
||||
toBeLessThan(value: number, message?: string): Expectation<T>;
|
||||
toBeLessThanOrEqualTo(value: number, messasge?: string): Expectation<T>;
|
||||
toBeFewerThan(value: number, message?: string): Expectation<T>;
|
||||
toBeGreaterThan(value: number, message?: string): Expectation<T>;
|
||||
toBeGreaterThanOrEqualTo(value: number, messasge?: string): Expectation<T>;
|
||||
toBeMoreThan(value: number, message?: string): Expectation<T>;
|
||||
|
||||
toInclude<U>(value: any, compareValues?: CompareValues<U>, message?: string): Expectation<T>;
|
||||
toContain<U>(value: any, compareValues?: CompareValues<U>, message?: string): Expectation<T>;
|
||||
toExclude<U>(value: any, compareValues?: CompareValues<U>, message?: string): Expectation<T>;
|
||||
toNotContain<U>(value: any, compareValues?: CompareValues<U>, message?: string): Expectation<T>;
|
||||
|
||||
toIncludeKeys(keys: KeyType[], comparator?: Comparator, message?: string): Expectation<T>;
|
||||
toContainKeys(keys: KeyType[], comparator?: Comparator, message?: string): Expectation<T>;
|
||||
toExcludeKeys(keys: KeyType[], comparator?: Comparator, message?: string): Expectation<T>;
|
||||
toNotContainKeys(keys: KeyType[], comparator?: Comparator, message?: string): Expectation<T>;
|
||||
toNotIncludeKeys(keys: KeyType[], comparator?: Comparator, message?: string): Expectation<T>;
|
||||
toIncludeKey(key: KeyType, comparator?: Comparator, message?: string): Expectation<T>;
|
||||
toContainKey(key: KeyType, comparator?: Comparator, message?: string): Expectation<T>;
|
||||
toExcludeKey(key: KeyType, comparator?: Comparator, message?: string): Expectation<T>;
|
||||
toNotContainKey(key: KeyType, comparator?: Comparator, message?: string): Expectation<T>;
|
||||
toNotIncludeKey(key: KeyType, comparator?: Comparator, message?: string): Expectation<T>;
|
||||
|
||||
toHaveBeenCalled(message?: string): Expectation<T>;
|
||||
toNotHaveBeenCalled(message?: string): Expectation<T>;
|
||||
toHaveBeenCalledWith(...args: any[]): Expectation<T>;
|
||||
|
||||
// deprecated
|
||||
withContext(context: any): Expectation<T>;
|
||||
withArgs(...args: any[]): Expectation<T>;
|
||||
}
|
||||
|
||||
export interface Extension {
|
||||
[name: string]: (args?: Array<any>) => void;
|
||||
[name: string]: (args?: any[]) => void;
|
||||
}
|
||||
|
||||
export interface Call {
|
||||
context: Spy;
|
||||
arguments: Array<any>;
|
||||
export interface Call<T> {
|
||||
context: T;
|
||||
arguments: any[];
|
||||
}
|
||||
|
||||
export interface Spy {
|
||||
__isSpy: Boolean;
|
||||
calls: Array<Call>;
|
||||
andCall(fn: Function): Spy;
|
||||
andCallThrough(): Spy;
|
||||
andThrow(object: Object): Spy;
|
||||
andReturn(value: any): Spy;
|
||||
getLastCall(): Call;
|
||||
export interface Spy<T> {
|
||||
(...args: any[]): void;
|
||||
__isSpy: boolean;
|
||||
calls: Array<Call<T>>;
|
||||
andCall(fn: (...args: any[]) => any): Spy<T>;
|
||||
andCallThrough(): Spy<T>;
|
||||
andThrow(object: {}): Spy<T>;
|
||||
andReturn(value: any): Spy<T>;
|
||||
getLastCall(): Call<T>;
|
||||
restore(): void;
|
||||
destroy(): void;
|
||||
reset(): void;
|
||||
}
|
||||
|
||||
|
||||
export function createSpy(fn?: Function, restore?: Function): Spy;
|
||||
export function spyOn(object: Object, methodName: string): Spy;
|
||||
export function isSpy(object: any): Boolean;
|
||||
export function createSpy(fn?: (...args: any[]) => any, restore?: (...args: any[]) => any): Spy<any>;
|
||||
export function spyOn<T>(object: T, methodName: string): Spy<T>;
|
||||
export function isSpy(object: {}): boolean;
|
||||
export function restoreSpies(): void;
|
||||
export function assert(condition: any, messageFormat: string, ...extraArgs: Array<any>): void;
|
||||
export function assert(condition: boolean, messageFormat: string, ...extraArgs: any[]): void;
|
||||
export function extend(extension: Extension): void;
|
||||
|
||||
}
|
||||
declare function expect(actual: any): expect.Expectation;
|
||||
|
||||
declare function expect<T>(actual: T): expect.Expectation<T>;
|
||||
|
||||
export = expect;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
Reference in New Issue
Block a user