// Type definitions for chai-as-promised // Project: https://github.com/domenic/chai-as-promised/ // Definitions by: jt000 , Yuki Kokubun // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module 'chai-as-promised' { function chaiAsPromised(chai: any, utils: any): void; namespace chaiAsPromised {} export = chaiAsPromised; } // tslint:disable:no-namespace ban-types member-ordering declare namespace Chai { // For BDD API interface Assertion extends LanguageChains, NumericComparison, TypeComparison { eventually: PromisedAssertion; fulfilled: PromisedAssertion; become(expected: any): PromisedAssertion; rejected(): PromisedAssertion; rejectedWith(expected: any, message?: string | RegExp): PromisedAssertion; notify(fn: Function): PromisedAssertion; } // Eventually does not have .then(), but PromisedAssertion have. interface Eventually extends PromisedLanguageChains, PromisedNumericComparison, PromisedTypeComparison { // From chai-as-promised become(expected: PromiseLike): PromisedAssertion; fulfilled: PromisedAssertion; rejected: () => PromisedAssertion; rejectedWith(expected: any, message?: string | RegExp): PromisedAssertion; notify(fn: Function): PromisedAssertion; // From chai not: PromisedAssertion; deep: PromisedDeep; all: PromisedKeyFilter; a: PromisedTypeComparison; an: PromisedTypeComparison; include: PromisedInclude; contain: PromisedInclude; ok: PromisedAssertion; true: () => PromisedAssertion; false: () => PromisedAssertion; null: PromisedAssertion; undefined: PromisedAssertion; exist: PromisedAssertion; empty: PromisedAssertion; arguments: PromisedAssertion; Arguments: PromisedAssertion; equal: PromisedEqual; equals: PromisedEqual; eq: PromisedEqual; eql: PromisedEqual; eqls: PromisedEqual; property: PromisedProperty; ownProperty: PromisedOwnProperty; haveOwnProperty: PromisedOwnProperty; length: PromisedLength; lengthOf: PromisedLength; match(regexp: RegExp | string, message?: string): PromisedAssertion; string(string: string, message?: string): PromisedAssertion; keys: PromisedKeys; key(string: string): PromisedAssertion; throw: PromisedThrow; throws: PromisedThrow; Throw: PromisedThrow; respondTo(method: string, message?: string): PromisedAssertion; itself: PromisedAssertion; satisfy(matcher: Function, message?: string): PromisedAssertion; closeTo(expected: number, delta: number, message?: string): PromisedAssertion; members: PromisedMembers; } interface PromisedAssertion extends Eventually, PromiseLike {} interface PromisedLanguageChains { eventually: Eventually; // From chai to: PromisedAssertion; be: PromisedAssertion; been: PromisedAssertion; is: PromisedAssertion; that: PromisedAssertion; which: PromisedAssertion; and: PromisedAssertion; has: PromisedAssertion; have: PromisedAssertion; with: PromisedAssertion; at: PromisedAssertion; of: PromisedAssertion; same: PromisedAssertion; } interface PromisedNumericComparison { above: PromisedNumberComparer; gt: PromisedNumberComparer; greaterThan: PromisedNumberComparer; least: PromisedNumberComparer; gte: PromisedNumberComparer; below: PromisedNumberComparer; lt: PromisedNumberComparer; lessThan: PromisedNumberComparer; most: PromisedNumberComparer; lte: PromisedNumberComparer; within(start: number, finish: number, message?: string): PromisedAssertion; } type PromisedNumberComparer = (value: number, message?: string) => PromisedAssertion; interface PromisedTypeComparison { (type: string, message?: string): PromisedAssertion; instanceof: PromisedInstanceOf; instanceOf: PromisedInstanceOf; } type PromisedInstanceOf = (constructor: Object, message?: string) => PromisedAssertion; interface PromisedDeep { equal: PromisedEqual; include: PromisedInclude; property: PromisedProperty; } interface PromisedKeyFilter { keys: PromisedKeys; } type PromisedEqual = (value: any, message?: string) => PromisedAssertion; type PromisedProperty = (name: string, value?: any, message?: string) => PromisedAssertion; type PromisedOwnProperty = (name: string, message?: string) => PromisedAssertion; interface PromisedLength extends PromisedLanguageChains, PromisedNumericComparison { (length: number, message?: string): PromisedAssertion; } interface PromisedInclude { (value: Object | string | number, message?: string): PromisedAssertion; keys: PromisedKeys; members: PromisedMembers; all: PromisedKeyFilter; } interface PromisedKeys { (...keys: string[]): PromisedAssertion; (keys: any[]): PromisedAssertion; } interface PromisedThrow { (): PromisedAssertion; (expected: string | RegExp, message?: string): PromisedAssertion; (constructor: Error | Function, expected?: string | RegExp, message?: string): PromisedAssertion; } type PromisedMembers = (set: any[], message?: string) => PromisedAssertion; // For Assert API interface Assert { eventually: PromisedAssert; isFulfilled(promise: PromiseLike, message?: string): PromiseLike; becomes(promise: PromiseLike, expected: any, message?: string): PromiseLike; doesNotBecome(promise: PromiseLike, expected: any, message?: string): PromiseLike; isRejected(promise: PromiseLike, message?: string): PromiseLike; isRejected(promise: PromiseLike, expected: any | RegExp, message?: string): PromiseLike; notify(fn: Function): PromiseLike; } export interface PromisedAssert { fail(actual?: any, expected?: any, msg?: string, operator?: string): PromiseLike; ok(val: any, msg?: string): PromiseLike; notOk(val: any, msg?: string): PromiseLike; equal(act: any, exp: any, msg?: string): PromiseLike; notEqual(act: any, exp: any, msg?: string): PromiseLike; strictEqual(act: any, exp: any, msg?: string): PromiseLike; notStrictEqual(act: any, exp: any, msg?: string): PromiseLike; deepEqual(act: any, exp: any, msg?: string): PromiseLike; notDeepEqual(act: any, exp: any, msg?: string): PromiseLike; isTrue(val: any, msg?: string): PromiseLike; isFalse(val: any, msg?: string): PromiseLike; isNull(val: any, msg?: string): PromiseLike; isNotNull(val: any, msg?: string): PromiseLike; isUndefined(val: any, msg?: string): PromiseLike; isDefined(val: any, msg?: string): PromiseLike; isFunction(val: any, msg?: string): PromiseLike; isNotFunction(val: any, msg?: string): PromiseLike; isObject(val: any, msg?: string): PromiseLike; isNotObject(val: any, msg?: string): PromiseLike; isArray(val: any, msg?: string): PromiseLike; isNotArray(val: any, msg?: string): PromiseLike; isString(val: any, msg?: string): PromiseLike; isNotString(val: any, msg?: string): PromiseLike; isNumber(val: any, msg?: string): PromiseLike; isNotNumber(val: any, msg?: string): PromiseLike; isBoolean(val: any, msg?: string): PromiseLike; isNotBoolean(val: any, msg?: string): PromiseLike; typeOf(val: any, type: string, msg?: string): PromiseLike; notTypeOf(val: any, type: string, msg?: string): PromiseLike; instanceOf(val: any, type: Function, msg?: string): PromiseLike; notInstanceOf(val: any, type: Function, msg?: string): PromiseLike; include(exp: string | any[], inc: any, msg?: string): PromiseLike; notInclude(exp: string | any[], inc: any, msg?: string): PromiseLike; match(exp: any, re: RegExp, msg?: string): PromiseLike; notMatch(exp: any, re: RegExp, msg?: string): PromiseLike; property(obj: Object, prop: string, msg?: string): PromiseLike; notProperty(obj: Object, prop: string, msg?: string): PromiseLike; deepProperty(obj: Object, prop: string, msg?: string): PromiseLike; notDeepProperty(obj: Object, prop: string, msg?: string): PromiseLike; propertyVal(obj: Object, prop: string, val: any, msg?: string): PromiseLike; propertyNotVal(obj: Object, prop: string, val: any, msg?: string): PromiseLike; deepPropertyVal(obj: Object, prop: string, val: any, msg?: string): PromiseLike; deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string): PromiseLike; lengthOf(exp: any, len: number, msg?: string): PromiseLike; // alias frenzy throw(fn: Function, msg?: string): PromiseLike; throw(fn: Function, regExp: RegExp): PromiseLike; throw(fn: Function, errType: Function, msg?: string): PromiseLike; throw(fn: Function, errType: Function, regExp: RegExp): PromiseLike; throws(fn: Function, msg?: string): PromiseLike; throws(fn: Function, regExp: RegExp): PromiseLike; throws(fn: Function, errType: Function, msg?: string): PromiseLike; throws(fn: Function, errType: Function, regExp: RegExp): PromiseLike; Throw(fn: Function, msg?: string): PromiseLike; Throw(fn: Function, regExp: RegExp): PromiseLike; Throw(fn: Function, errType: Function, msg?: string): PromiseLike; Throw(fn: Function, errType: Function, regExp: RegExp): PromiseLike; doesNotThrow(fn: Function, msg?: string): PromiseLike; doesNotThrow(fn: Function, regExp: RegExp): PromiseLike; doesNotThrow(fn: Function, errType: Function, msg?: string): PromiseLike; doesNotThrow(fn: Function, errType: Function, regExp: RegExp): PromiseLike; operator(val: any, operator: string, val2: any, msg?: string): PromiseLike; closeTo(act: number, exp: number, delta: number, msg?: string): PromiseLike; sameMembers(set1: any[], set2: any[], msg?: string): PromiseLike; includeMembers(set1: any[], set2: any[], msg?: string): PromiseLike; ifError(val: any, msg?: string): PromiseLike; } }