2019-04-05 18:45:23 +02:00
|
|
|
/* eslint-disable */
|
2019-03-25 17:56:48 +01:00
|
|
|
|
|
|
|
// Type definitions for expect.js 0.3.1
|
|
|
|
// Project: https://github.com/Automattic/expect.js
|
|
|
|
// Definitions by: Teppei Sato <https://github.com/teppeis>
|
|
|
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
|
|
// License: MIT
|
|
|
|
|
|
|
|
export default function expect(target?: any): Root;
|
|
|
|
|
|
|
|
interface Assertion {
|
|
|
|
/**
|
|
|
|
* Assert typeof / instanceof.
|
|
|
|
*/
|
|
|
|
an: An;
|
|
|
|
/**
|
|
|
|
* Check if the value is truthy
|
|
|
|
*/
|
|
|
|
ok(): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates an anonymous function which calls fn with arguments.
|
|
|
|
*/
|
|
|
|
withArgs(...args: any[]): Root;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Assert that the function throws.
|
|
|
|
*
|
|
|
|
* @param fn callback to match error string against
|
|
|
|
*/
|
|
|
|
throwError(fn?: (exception: any) => void): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Assert that the function throws.
|
|
|
|
*
|
|
|
|
* @param fn callback to match error string against
|
|
|
|
*/
|
|
|
|
throwException(fn?: (exception: any) => void): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Assert that the function throws.
|
|
|
|
*
|
|
|
|
* @param regexp regexp to match error string against
|
|
|
|
*/
|
|
|
|
throwError(regexp: RegExp): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Assert that the function throws.
|
|
|
|
*
|
|
|
|
* @param fn callback to match error string against
|
|
|
|
*/
|
|
|
|
throwException(regexp: RegExp): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if the array is empty.
|
|
|
|
*/
|
|
|
|
empty(): Assertion;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if the obj exactly equals another.
|
|
|
|
*/
|
2019-10-26 15:51:45 +02:00
|
|
|
equal(obj: any, msg?: string): Assertion;
|
2019-03-25 17:56:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if the obj sortof equals another.
|
|
|
|
*/
|
2019-10-26 15:51:45 +02:00
|
|
|
eql(obj: any, msg?: string): Assertion;
|
2019-03-25 17:56:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Assert within start to finish (inclusive).
|
|
|
|
*
|
|
|
|
* @param start
|
|
|
|
* @param finish
|
|
|
|
*/
|
2019-10-26 15:51:45 +02:00
|
|
|
within(start: number, finish: number, msg?: string): Assertion;
|
2019-03-25 17:56:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Assert typeof.
|
|
|
|
*/
|
|
|
|
a(type: string): Assertion;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Assert instanceof.
|
|
|
|
*/
|
|
|
|
a(type: Function): Assertion;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Assert numeric value above n.
|
|
|
|
*/
|
2019-10-26 15:51:45 +02:00
|
|
|
greaterThan(n: number, msg?: string): Assertion;
|
2019-03-25 17:56:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Assert numeric value above n.
|
|
|
|
*/
|
2019-10-26 15:51:45 +02:00
|
|
|
above(n: number, msg?: string): Assertion;
|
2019-03-25 17:56:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Assert numeric value below n.
|
|
|
|
*/
|
2019-10-26 15:51:45 +02:00
|
|
|
lessThan(n: number, msg?: string): Assertion;
|
2019-03-25 17:56:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Assert numeric value below n.
|
|
|
|
*/
|
2019-10-26 15:51:45 +02:00
|
|
|
below(n: number, msg?: string): Assertion;
|
2019-03-25 17:56:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Assert string value matches regexp.
|
|
|
|
*
|
|
|
|
* @param regexp
|
|
|
|
*/
|
2019-10-26 15:51:45 +02:00
|
|
|
match(regexp: RegExp, msg?: string): Assertion;
|
2019-03-25 17:56:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Assert property "length" exists and has value of n.
|
|
|
|
*
|
|
|
|
* @param n
|
|
|
|
*/
|
2019-10-26 15:51:45 +02:00
|
|
|
length(n: number, msg?: string): Assertion;
|
2019-03-25 17:56:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Assert property name exists, with optional val.
|
|
|
|
*
|
|
|
|
* @param name
|
|
|
|
* @param val
|
|
|
|
*/
|
|
|
|
property(name: string, val?: any): Assertion;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Assert that string contains str.
|
|
|
|
*/
|
2019-10-26 15:51:45 +02:00
|
|
|
contain(str: string, msg?: string): Assertion;
|
|
|
|
string(str: string, msg?: string): Assertion;
|
2019-03-25 17:56:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Assert that the array contains obj.
|
|
|
|
*/
|
2019-10-26 15:51:45 +02:00
|
|
|
contain(obj: any, msg?: string): Assertion;
|
|
|
|
string(obj: any, msg?: string): Assertion;
|
2019-03-25 17:56:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Assert exact keys or inclusion of keys by using the `.own` modifier.
|
|
|
|
*/
|
|
|
|
key(keys: string[]): Assertion;
|
|
|
|
/**
|
|
|
|
* Assert exact keys or inclusion of keys by using the `.own` modifier.
|
|
|
|
*/
|
|
|
|
key(...keys: string[]): Assertion;
|
|
|
|
/**
|
|
|
|
* Assert exact keys or inclusion of keys by using the `.own` modifier.
|
|
|
|
*/
|
|
|
|
keys(keys: string[]): Assertion;
|
|
|
|
/**
|
|
|
|
* Assert exact keys or inclusion of keys by using the `.own` modifier.
|
|
|
|
*/
|
|
|
|
keys(...keys: string[]): Assertion;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Assert a failure.
|
|
|
|
*/
|
|
|
|
fail(message?: string): Assertion;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface Root extends Assertion {
|
|
|
|
not: Not;
|
|
|
|
to: To;
|
|
|
|
only: Only;
|
|
|
|
have: Have;
|
|
|
|
be: Be;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface Be extends Assertion {
|
|
|
|
/**
|
|
|
|
* Checks if the obj exactly equals another.
|
|
|
|
*/
|
|
|
|
(obj: any): Assertion;
|
|
|
|
|
|
|
|
an: An;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface An extends Assertion {
|
|
|
|
/**
|
|
|
|
* Assert typeof.
|
|
|
|
*/
|
|
|
|
(type: string): Assertion;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Assert instanceof.
|
|
|
|
*/
|
|
|
|
(type: Function): Assertion;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface Not extends NotBase {
|
|
|
|
to: ToBase;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface NotBase extends Assertion {
|
|
|
|
be: Be;
|
|
|
|
have: Have;
|
|
|
|
include: Assertion;
|
|
|
|
only: Only;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface To extends ToBase {
|
|
|
|
not: NotBase;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface ToBase extends Assertion {
|
|
|
|
be: Be;
|
|
|
|
have: Have;
|
|
|
|
include: Assertion;
|
|
|
|
only: Only;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface Only extends Assertion {
|
|
|
|
have: Have;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface Have extends Assertion {
|
|
|
|
own: Assertion;
|
|
|
|
}
|