UNPKG

21.3 kBTypeScriptView Raw
1// Type definitions for chai-as-promised 7.1.0
2// Project: https://github.com/domenic/chai-as-promised/
3// Definitions by: jt000 <https://github.com/jt000>,
4// Yuki Kokubun <https://github.com/Kuniwak>,
5// Leonard Thieu <https://github.com/leonard-thieu>,
6// Mike Lazer-Walker <https://github.com/lazerwalker>,
7// Matt Bishop <https://github.com/mattbishop>
8// William Orr <https://github.com/worr>
9// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
10// TypeScript Version: 3.0
11
12/// <reference types="chai" />
13
14declare module 'chai-as-promised' {
15 interface ChaiAsPromised extends Chai.ChaiPlugin {
16 transferPromiseness(assertion: Chai.PromisedAssertion, promise: PromiseLike<any>): void;
17 transformAsserterArgs(values: any[]): any;
18 }
19
20 const chaiAsPromised: ChaiAsPromised;
21 export = chaiAsPromised;
22}
23
24declare namespace Chai {
25
26 // For BDD API
27 interface Assertion extends LanguageChains, NumericComparison, TypeComparison {
28 eventually: PromisedAssertion;
29 become(expected: any): PromisedAssertion;
30 fulfilled: PromisedAssertion;
31 rejected: PromisedAssertion;
32 rejectedWith: PromisedThrow;
33 notify(fn: Function): PromisedAssertion;
34 }
35
36 // Eventually does not have .then(), but PromisedAssertion have.
37 interface Eventually extends PromisedLanguageChains, PromisedNumericComparison, PromisedTypeComparison {
38 // From chai-as-promised
39 become(expected: any): PromisedAssertion;
40 fulfilled: PromisedAssertion;
41 rejected: PromisedAssertion;
42 rejectedWith: PromisedThrow;
43 notify(fn: Function): PromisedAssertion;
44
45 // From chai
46 not: PromisedAssertion;
47 deep: PromisedDeep;
48 ordered: PromisedOrdered;
49 nested: PromisedNested;
50 any: PromisedKeyFilter;
51 all: PromisedKeyFilter;
52 a: PromisedTypeComparison;
53 an: PromisedTypeComparison;
54 include: PromisedInclude;
55 contain: PromisedInclude;
56 ok: PromisedAssertion;
57 true: PromisedAssertion;
58 false: PromisedAssertion;
59 null: PromisedAssertion;
60 undefined: PromisedAssertion;
61 NaN: PromisedAssertion;
62 exist: PromisedAssertion;
63 empty: PromisedAssertion;
64 arguments: PromisedAssertion;
65 Arguments: PromisedAssertion;
66 equal: PromisedEqual;
67 equals: PromisedEqual;
68 eq: PromisedEqual;
69 eql: PromisedEqual;
70 eqls: PromisedEqual;
71 property: PromisedProperty;
72 ownProperty: PromisedOwnProperty;
73 haveOwnProperty: PromisedOwnProperty;
74 ownPropertyDescriptor: PromisedOwnPropertyDescriptor;
75 haveOwnPropertyDescriptor: PromisedOwnPropertyDescriptor;
76 length: PromisedLength;
77 lengthOf: PromisedLength;
78 match: PromisedMatch;
79 matches: PromisedMatch;
80 string(string: string, message?: string): PromisedAssertion;
81 keys: PromisedKeys;
82 key(string: string): PromisedAssertion;
83 throw: PromisedThrow;
84 throws: PromisedThrow;
85 Throw: PromisedThrow;
86 respondTo: PromisedRespondTo;
87 respondsTo: PromisedRespondTo;
88 itself: PromisedAssertion;
89 satisfy: PromisedSatisfy;
90 satisfies: PromisedSatisfy;
91 closeTo: PromisedCloseTo;
92 approximately: PromisedCloseTo;
93 members: PromisedMembers;
94 increase: PromisedPropertyChange;
95 increases: PromisedPropertyChange;
96 decrease: PromisedPropertyChange;
97 decreases: PromisedPropertyChange;
98 change: PromisedPropertyChange;
99 changes: PromisedPropertyChange;
100 extensible: PromisedAssertion;
101 sealed: PromisedAssertion;
102 frozen: PromisedAssertion;
103 oneOf(list: any[], message?: string): PromisedAssertion;
104 }
105
106 interface PromisedAssertion extends Eventually, PromiseLike<any> {
107 }
108
109 interface PromisedLanguageChains {
110 eventually: Eventually;
111
112 // From chai
113 to: PromisedAssertion;
114 be: PromisedAssertion;
115 been: PromisedAssertion;
116 is: PromisedAssertion;
117 that: PromisedAssertion;
118 which: PromisedAssertion;
119 and: PromisedAssertion;
120 has: PromisedAssertion;
121 have: PromisedAssertion;
122 with: PromisedAssertion;
123 at: PromisedAssertion;
124 of: PromisedAssertion;
125 same: PromisedAssertion;
126 but: PromisedAssertion;
127 does: PromisedAssertion;
128 }
129
130 interface PromisedNumericComparison {
131 above: PromisedNumberComparer;
132 gt: PromisedNumberComparer;
133 greaterThan: PromisedNumberComparer;
134 least: PromisedNumberComparer;
135 gte: PromisedNumberComparer;
136 below: PromisedNumberComparer;
137 lt: PromisedNumberComparer;
138 lessThan: PromisedNumberComparer;
139 most: PromisedNumberComparer;
140 lte: PromisedNumberComparer;
141 within(start: number, finish: number, message?: string): PromisedAssertion;
142 }
143
144 interface PromisedNumberComparer {
145 (value: number, message?: string): PromisedAssertion;
146 }
147
148 interface PromisedTypeComparison {
149 (type: string, message?: string): PromisedAssertion;
150 instanceof: PromisedInstanceOf;
151 instanceOf: PromisedInstanceOf;
152 }
153
154 interface PromisedInstanceOf {
155 (constructor: Object, message?: string): PromisedAssertion;
156 }
157
158 interface PromisedCloseTo {
159 (expected: number, delta: number, message?: string): PromisedAssertion;
160 }
161
162 interface PromisedNested {
163 include: PromisedInclude;
164 property: PromisedProperty;
165 members: PromisedMembers;
166 }
167
168 interface PromisedDeep {
169 equal: PromisedEqual;
170 equals: PromisedEqual;
171 eq: PromisedEqual;
172 include: PromisedInclude;
173 property: PromisedProperty;
174 members: PromisedMembers;
175 ordered: PromisedOrdered
176 }
177
178 interface PromisedOrdered {
179 members: PromisedMembers;
180 }
181
182 interface PromisedKeyFilter {
183 keys: PromisedKeys;
184 }
185
186 interface PromisedEqual {
187 (value: any, message?: string): PromisedAssertion;
188 }
189
190 interface PromisedProperty {
191 (name: string | symbol, value?: any, message?: string): PromisedAssertion;
192 }
193
194 interface PromisedOwnProperty {
195 (name: string | symbol, message?: string): PromisedAssertion;
196 }
197
198 interface PromisedOwnPropertyDescriptor {
199 (name: string | symbol, descriptor: PropertyDescriptor, message?: string): PromisedAssertion;
200 (name: string | symbol, message?: string): PromisedAssertion;
201 }
202
203 interface PromisedLength extends PromisedLanguageChains, PromisedNumericComparison {
204 (length: number, message?: string): PromisedAssertion;
205 }
206
207 interface PromisedInclude {
208 (value: Object, message?: string): PromisedAssertion;
209 (value: string, message?: string): PromisedAssertion;
210 (value: number, message?: string): PromisedAssertion;
211 keys: PromisedKeys;
212 deep: PromisedDeep;
213 ordered: PromisedOrdered;
214 members: PromisedMembers;
215 any: PromisedKeyFilter;
216 all: PromisedKeyFilter;
217 }
218
219 interface PromisedMatch {
220 (regexp: RegExp | string, message?: string): PromisedAssertion;
221 }
222
223 interface PromisedKeys {
224 (...keys: string[]): PromisedAssertion;
225 (keys: any[]): PromisedAssertion;
226 (keys: Object): PromisedAssertion;
227 }
228
229 interface PromisedThrow {
230 (): PromisedAssertion;
231 (expected: string | RegExp, message?: string): PromisedAssertion;
232 (constructor: Error | Function, expected?: string | RegExp, message?: string): PromisedAssertion;
233 }
234
235 interface PromisedRespondTo {
236 (method: string, message?: string): PromisedAssertion;
237 }
238
239 interface PromisedSatisfy {
240 (matcher: Function, message?: string): PromisedAssertion;
241 }
242
243 interface PromisedMembers {
244 (set: any[], message?: string): PromisedAssertion;
245 }
246
247 interface PromisedPropertyChange {
248 (object: Object, property: string, message?: string): PromisedAssertion;
249 }
250
251 // For Assert API
252 interface Assert {
253 eventually: PromisedAssert;
254 isFulfilled(promise: PromiseLike<any>, message?: string): PromiseLike<void>;
255 becomes(promise: PromiseLike<any>, expected: any, message?: string): PromiseLike<void>;
256 doesNotBecome(promise: PromiseLike<any>, expected: any, message?: string): PromiseLike<void>;
257 isRejected(promise: PromiseLike<any>, message?: string): PromiseLike<void>;
258 isRejected(promise: PromiseLike<any>, expected: any, message?: string): PromiseLike<void>;
259 isRejected(promise: PromiseLike<any>, match: RegExp, message?: string): PromiseLike<void>;
260 notify(fn: Function): PromiseLike<void>;
261 }
262
263 export interface PromisedAssert {
264 fail(actual?: any, expected?: any, msg?: string, operator?: string): PromiseLike<void>;
265
266 isOk(val: any, msg?: string): PromiseLike<void>;
267 ok(val: any, msg?: string): PromiseLike<void>;
268 isNotOk(val: any, msg?: string): PromiseLike<void>;
269 notOk(val: any, msg?: string): PromiseLike<void>;
270
271 equal(act: any, exp: any, msg?: string): PromiseLike<void>;
272 notEqual(act: any, exp: any, msg?: string): PromiseLike<void>;
273
274 strictEqual(act: any, exp: any, msg?: string): PromiseLike<void>;
275 notStrictEqual(act: any, exp: any, msg?: string): PromiseLike<void>;
276
277 deepEqual(act: any, exp: any, msg?: string): PromiseLike<void>;
278 notDeepEqual(act: any, exp: any, msg?: string): PromiseLike<void>;
279
280 isAbove(val: number, above: number, msg?: string): PromiseLike<void>;
281 isAtLeast(val: number, atLeast: number, msg?: string): PromiseLike<void>;
282 isAtBelow(val: number, below: number, msg?: string): PromiseLike<void>;
283 isAtMost(val: number, atMost: number, msg?: string): PromiseLike<void>;
284
285 isTrue(val: any, msg?: string): PromiseLike<void>;
286 isFalse(val: any, msg?: string): PromiseLike<void>;
287
288 isNotTrue(val: any, msg?: string): PromiseLike<void>;
289 isNotFalse(val: any, msg?: string): PromiseLike<void>;
290
291 isNull(val: any, msg?: string): PromiseLike<void>;
292 isNotNull(val: any, msg?: string): PromiseLike<void>;
293
294 isNaN(val: any, msg?: string): PromiseLike<void>;
295 isNotNaN(val: any, msg?: string): PromiseLike<void>;
296
297 exists(val: any, msg?: string): PromiseLike<void>;
298 notExists(val: any, msg?: string): PromiseLike<void>;
299
300 isUndefined(val: any, msg?: string): PromiseLike<void>;
301 isDefined(val: any, msg?: string): PromiseLike<void>;
302
303 isFunction(val: any, msg?: string): PromiseLike<void>;
304 isNotFunction(val: any, msg?: string): PromiseLike<void>;
305
306 isObject(val: any, msg?: string): PromiseLike<void>;
307 isNotObject(val: any, msg?: string): PromiseLike<void>;
308
309 isArray(val: any, msg?: string): PromiseLike<void>;
310 isNotArray(val: any, msg?: string): PromiseLike<void>;
311
312 isString(val: any, msg?: string): PromiseLike<void>;
313 isNotString(val: any, msg?: string): PromiseLike<void>;
314
315 isNumber(val: any, msg?: string): PromiseLike<void>;
316 isNotNumber(val: any, msg?: string): PromiseLike<void>;
317 isFinite(val: number, msg?: string): PromiseLike<void>;
318
319 isBoolean(val: any, msg?: string): PromiseLike<void>;
320 isNotBoolean(val: any, msg?: string): PromiseLike<void>;
321
322 typeOf(val: any, type: string, msg?: string): PromiseLike<void>;
323 notTypeOf(val: any, type: string, msg?: string): PromiseLike<void>;
324
325 instanceOf(val: any, type: Function, msg?: string): PromiseLike<void>;
326 notInstanceOf(val: any, type: Function, msg?: string): PromiseLike<void>;
327
328 include(exp: string, inc: any, msg?: string): PromiseLike<void>;
329 include(exp: any[], inc: any, msg?: string): PromiseLike<void>;
330
331 notInclude(exp: string, inc: any, msg?: string): PromiseLike<void>;
332 notInclude(exp: any[], inc: any, msg?: string): PromiseLike<void>;
333
334 deepInclude(exp: string, inc: any, msg?: string): PromiseLike<void>;
335 deepInclude(exp: any[], inc: any, msg?: string): PromiseLike<void>;
336
337 notDeepInclude(exp: string, inc: any, msg?: string): PromiseLike<void>;
338 notDeepInclude(exp: any[], inc: any, msg?: string): PromiseLike<void>;
339
340 nestedInclude(exp: Object, inc: Object, msg?: string): PromiseLike<void>;
341 notNestedInclude(exp: Object, inc: Object, msg?: string): PromiseLike<void>;
342
343 deepNestedInclude(exp: Object, inc: Object, msg?: string): PromiseLike<void>;
344 notDeepNestedInclude(exp: Object, inc: Object, msg?: string): PromiseLike<void>;
345
346 ownInclude(exp: Object, inc: Object, msg?: string): PromiseLike<void>;
347 notOwnInclude(exp: Object, inc: Object, msg?: string): PromiseLike<void>;
348
349 deepOwnInclude(exp: Object, inc: Object, msg?: string): PromiseLike<void>;
350 notDeepOwnInclude(exp: Object, inc: Object, msg?: string): PromiseLike<void>;
351
352 match(exp: any, re: RegExp, msg?: string): PromiseLike<void>;
353 notMatch(exp: any, re: RegExp, msg?: string): PromiseLike<void>;
354
355 property(obj: Object, prop: string, msg?: string): PromiseLike<void>;
356 notProperty(obj: Object, prop: string, msg?: string): PromiseLike<void>;
357 deepProperty(obj: Object, prop: string, msg?: string): PromiseLike<void>;
358 notDeepProperty(obj: Object, prop: string, msg?: string): PromiseLike<void>;
359
360 propertyVal(obj: Object, prop: string, val: any, msg?: string): PromiseLike<void>;
361 propertyNotVal(obj: Object, prop: string, val: any, msg?: string): PromiseLike<void>;
362
363 deepPropertyVal(obj: Object, prop: string, val: any, msg?: string): PromiseLike<void>;
364 deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string): PromiseLike<void>;
365
366 nestedProperty(obj: object, prop: string, msg?: string): PromiseLike<void>;
367 notNestedProperty(obj: object, prop: string, msg?: string): PromiseLike<void>;
368 nestedPropertyVal(obj: object, prop: string, val: any, msg?: string): PromiseLike<void>;
369 notNestedPropertyVal(obj: object, prop: string, val: any, msg?: string): PromiseLike<void>;
370
371 deepNestedPropertyVal(obj: object, prop: string, val: any, msg?: string): PromiseLike<void>;
372 notDeepNestedPropertyVal(obj: object, prop: string, val: any, msg?: string): PromiseLike<void>;
373
374 lengthOf(exp: any, len: number, msg?: string): PromiseLike<void>;
375
376 hasAnyKeys(obj: any, keys: any[], msg?: string): PromiseLike<void>;
377 hasAnyKeys(obj: any, keys: object, msg?: string): PromiseLike<void>;
378
379 hasAllKeys(obj: any, keys: any[], msg?: string): PromiseLike<void>;
380 hasAllKeys(obj: any, keys: object, msg?: string): PromiseLike<void>;
381
382 containsAllKeys(obj: any, keys: any[], msg?: string): PromiseLike<void>;
383 containsAllKeys(obj: any, keys: object, msg?: string): PromiseLike<void>;
384
385 doesNotHaveAnyKeys(obj: any, keys: any[], msg?: string): PromiseLike<void>;
386 doesNotHaveAnyKeys(obj: any, keys: object, msg?: string): PromiseLike<void>;
387
388 doesNotHaveAllKeys(obj: any, keys: any[], msg?: string): PromiseLike<void>;
389 doesNotHaveAllKeys(obj: any, keys: object, msg?: string): PromiseLike<void>;
390
391 hasAnyDeepKeys(obj: any, keys: any[], msg?: string): PromiseLike<void>;
392 hasAnyDeepKeys(obj: any, keys: object, msg?: string): PromiseLike<void>;
393
394 hasAllDeepKeys(obj: any, keys: any[], msg?: string): PromiseLike<void>;
395 hasAllDeepKeys(obj: any, keys: object, msg?: string): PromiseLike<void>;
396
397 containsAllDeepKeys(obj: any, keys: any[], msg?: string): PromiseLike<void>;
398 containsAllDeepKeys(obj: any, keys: object, msg?: string): PromiseLike<void>;
399
400 doesNotHaveAnyDeepKeys(obj: any, keys: any[], msg?: string): PromiseLike<void>;
401 doesNotHaveAnyDeepKeys(obj: any, keys: object, msg?: string): PromiseLike<void>;
402
403 doesNotHaveAllDeepKeys(obj: any, keys: any[], msg?: string): PromiseLike<void>;
404 doesNotHaveAllDeepKeys(obj: any, keys: object, msg?: string): PromiseLike<void>;
405
406 //alias frenzy
407 throw(fn: Function, msg?: string): PromiseLike<void>;
408 throw(fn: Function, regExp: RegExp): PromiseLike<void>;
409 throw(fn: Function, errType: Function, msg?: string): PromiseLike<void>;
410 throw(fn: Function, errType: Function, regExp: RegExp): PromiseLike<void>;
411
412 throws(fn: Function, msg?: string): PromiseLike<void>;
413 throws(fn: Function, regExp: RegExp): PromiseLike<void>;
414 throws(fn: Function, errType: Function, msg?: string): PromiseLike<void>;
415 throws(fn: Function, errType: Function, regExp: RegExp): PromiseLike<void>;
416
417 Throw(fn: Function, msg?: string): PromiseLike<void>;
418 Throw(fn: Function, regExp: RegExp): PromiseLike<void>;
419 Throw(fn: Function, errType: Function, msg?: string): PromiseLike<void>;
420 Throw(fn: Function, errType: Function, regExp: RegExp): PromiseLike<void>;
421
422 doesNotThrow(fn: Function, msg?: string): PromiseLike<void>;
423 doesNotThrow(fn: Function, regExp: RegExp): PromiseLike<void>;
424 doesNotThrow(fn: Function, errType: Function, msg?: string): PromiseLike<void>;
425 doesNotThrow(fn: Function, errType: Function, regExp: RegExp): PromiseLike<void>;
426
427 operator(val: any, operator: string, val2: any, msg?: string): PromiseLike<void>;
428 closeTo(act: number, exp: number, delta: number, msg?: string): PromiseLike<void>;
429 approximately(act: number, exp: number, delta: number, msg?: string): PromiseLike<void>;
430
431 sameMembers(set1: any[], set2: any[], msg?: string): PromiseLike<void>;
432 sameDeepMembers(set1: any[], set2: any[], msg?: string): PromiseLike<void>;
433 sameOrderedMembers(set1: any[], set2: any[], msg?: string): PromiseLike<void>;
434 notSameOrderedMembers(set1: any[], set2: any[], msg?: string): PromiseLike<void>;
435 sameDeepOrderedMembers(set1: any[], set2: any[], msg?: string): PromiseLike<void>;
436 notSameDeepOrderedMembers(set1: any[], set2: any[], msg?: string): PromiseLike<void>;
437 includeOrderedMembers(set1: any[], set2: any[], msg?: string): PromiseLike<void>;
438 notIncludeOrderedMembers(set1: any[], set2: any[], msg?: string): PromiseLike<void>;
439 includeDeepOrderedMembers(set1: any[], set2: any[], msg?: string): PromiseLike<void>;
440 notIncludeDeepOrderedMembers(set1: any[], set2: any[], msg?: string): PromiseLike<void>;
441 includeMembers(set1: any[], set2: any[], msg?: string): PromiseLike<void>;
442 includeDeepMembers(set1: any[], set2: any[], msg?: string): PromiseLike<void>;
443
444 oneOf(val: any, list: any[], msg?: string): PromiseLike<void>;
445
446 changes(modifier: Function, obj: Object, property: string, msg?: string): PromiseLike<void>;
447 changesBy(modifier: Function, obj: object, property: string, change: number, msg?: string): PromiseLike<void>;
448 doesNotChange(modifier: Function, obj: Object, property: string, msg?: string): PromiseLike<void>;
449 changesButNotBy(modifier: Function, obj: object, property: string, change: number, msg?: string): PromiseLike<void>;
450 increases(modifier: Function, obj: Object, property: string, msg?: string): PromiseLike<void>;
451 increasesBy(modifier: Function, obj: Object, property: string, change: number, msg?: string): PromiseLike<void>;
452 doesNotIncrease(modifier: Function, obj: Object, property: string, msg?: string): PromiseLike<void>;
453 increasesButNotBy(modifier: Function, obj: Object, property: string, change: number, msg?: string): PromiseLike<void>;
454 decreases(modifier: Function, obj: Object, property: string, msg?: string): PromiseLike<void>;
455 decreasesBy(modifier: Function, obj: Object, property: string, change: number, msg?: string): PromiseLike<void>;
456 doesNotDecrease(modifier: Function, obj: Object, property: string, msg?: string): PromiseLike<void>;
457 decreasesButNotBy(modifier: Function, obj: Object, property: string, change: number, msg?: string): PromiseLike<void>;
458
459 ifError(val: any, msg?: string): PromiseLike<void>;
460
461 isExtensible(obj: Object, msg?: string): PromiseLike<void>;
462 isNotExtensible(obj: Object, msg?: string): PromiseLike<void>;
463
464 isSealed(obj: Object, msg?: string): PromiseLike<void>;
465 sealed(obj: Object, msg?: string): PromiseLike<void>;
466 isNotSealed(obj: Object, msg?: string): PromiseLike<void>;
467 notSealed(obj: Object, msg?: string): PromiseLike<void>;
468
469 isFrozen(obj: Object, msg?: string): PromiseLike<void>;
470 frozen(obj: Object, msg?: string): PromiseLike<void>;
471 isNotFrozen(obj: Object, msg?: string): PromiseLike<void>;
472 notFrozen(obj: Object, msg?: string): PromiseLike<void>;
473
474 isEmpty(val: any, msg?: string): PromiseLike<void>;
475 isNotEmpty(val: any, msg?: string): PromiseLike<void>;
476 }
477}