UNPKG

49.7 kBTypeScriptView Raw
1export interface AssertStatic extends Assert {
2}
3
4declare namespace Chai {
5 interface ChaiStatic {
6 use(fn: (chai: any, utils: any) => void): ChaiStatic;
7 assert: AssertStatic;
8 }
9}
10
11export type Operator = string; // "==" | "===" | ">" | ">=" | "<" | "<=" | "!=" | "!==";
12export type OperatorComparable = boolean | null | number | string | undefined | Date;
13
14export declare class Assert {
15 private _counts;
16 private _plannedCounts;
17 private _assertionStack;
18
19 /**
20 * Use chai plugins
21 */
22 static use(fn: (chai: any, utils: any) => void): Chai.ChaiStatic;
23 /**
24 * Plan for assertions
25 */
26 plan(count: number): void;
27
28 /**
29 * Throws a failure.
30 *
31 * @type T Type of the objects.
32 * @param actual Actual value.
33 * @param expected Potential expected value.
34 * @param message Message to display on error.
35 * @param operator Comparison operator, if not strict equality.
36 * @remarks Node.js assert module-compatible.
37 */
38 fail<T>(actual?: T, expected?: T, message?: string, operator?: Operator): void;
39
40 /**
41 * Asserts that object is truthy.
42 *
43 * @type T Type of object.
44 * @param object Object to test.
45 * @param message Message to display on error.
46 */
47 isOk<T>(value: T, message?: string): void;
48
49 /**
50 * Asserts that object is truthy.
51 *
52 * @type T Type of object.
53 * @param object Object to test.
54 * @param message Message to display on error.
55 */
56 ok<T>(value: T, message?: string): void;
57
58 /**
59 * Asserts that object is falsy.
60 *
61 * @type T Type of object.
62 * @param object Object to test.
63 * @param message Message to display on error.
64 */
65 isNotOk<T>(value: T, message?: string): void;
66
67 /**
68 * Asserts that object is falsy.
69 *
70 * @type T Type of object.
71 * @param object Object to test.
72 * @param message Message to display on error.
73 */
74 notOk<T>(value: T, message?: string): void;
75
76 /**
77 * Asserts non-strict equality (==) of actual and expected.
78 *
79 * @type T Type of the objects.
80 * @param actual Actual value.
81 * @param expected Potential expected value.
82 * @param message Message to display on error.
83 */
84 equal<T>(actual: T, expected: T, message?: string): void;
85
86 /**
87 * Asserts non-strict inequality (==) of actual and expected.
88 *
89 * @type T Type of the objects.
90 * @param actual Actual value.
91 * @param expected Potential expected value.
92 * @param message Message to display on error.
93 */
94 notEqual<T>(actual: T, expected: T, message?: string): void;
95
96 /**
97 * Asserts strict equality (===) of actual and expected.
98 *
99 * @type T Type of the objects.
100 * @param actual Actual value.
101 * @param expected Potential expected value.
102 * @param message Message to display on error.
103 */
104 strictEqual<T>(actual: T, expected: T, message?: string): void;
105
106 /**
107 * Asserts strict inequality (==) of actual and expected.
108 *
109 * @type T Type of the objects.
110 * @param actual Actual value.
111 * @param expected Potential expected value.
112 * @param message Message to display on error.
113 */
114 notStrictEqual<T>(actual: T, expected: T, message?: string): void;
115
116 /**
117 * Asserts that actual is deeply equal (==) to expected.
118 *
119 * @type T Type of the objects.
120 * @param actual Actual value.
121 * @param expected Potential expected value.
122 * @param message Message to display on error.
123 */
124 deepEqual<T>(actual: T, expected: T, message?: string): void;
125
126 /**
127 * Asserts that actual is not deeply equal (==) to expected.
128 *
129 * @type T Type of the objects.
130 * @param actual Actual value.
131 * @param expected Potential expected value.
132 * @param message Message to display on error.
133 */
134 notDeepEqual<T>(actual: T, expected: T, message?: string): void;
135
136 /**
137 * Asserts that actual is deeply strict equal (===) to expected.
138 *
139 * @type T Type of the objects.
140 * @param actual Actual value.
141 * @param expected Potential expected value.
142 * @param message Message to display on error.
143 */
144 deepStrictEqual<T>(actual: T, expected: T, message?: string): void;
145
146 /**
147 * Asserts valueToCheck is strictly greater than (>) valueToBeAbove.
148 *
149 * @param valueToCheck Actual value.
150 * @param valueToBeAbove Minimum Potential expected value.
151 * @param message Message to display on error.
152 */
153 isAbove(valueToCheck: number, valueToBeAbove: number, message?: string): void;
154
155 /**
156 * Asserts valueToCheck is greater than or equal to (>=) valueToBeAtLeast.
157 *
158 * @param valueToCheck Actual value.
159 * @param valueToBeAtLeast Minimum Potential expected value.
160 * @param message Message to display on error.
161 */
162 isAtLeast(valueToCheck: number, valueToBeAtLeast: number, message?: string): void;
163
164 /**
165 * Asserts valueToCheck is strictly less than (<) valueToBeBelow.
166 *
167 * @param valueToCheck Actual value.
168 * @param valueToBeBelow Minimum Potential expected value.
169 * @param message Message to display on error.
170 */
171 isBelow(valueToCheck: number, valueToBeBelow: number, message?: string): void;
172
173 /**
174 * Asserts valueToCheck is greater than or equal to (>=) valueToBeAtMost.
175 *
176 * @param valueToCheck Actual value.
177 * @param valueToBeAtMost Minimum Potential expected value.
178 * @param message Message to display on error.
179 */
180 isAtMost(valueToCheck: number, valueToBeAtMost: number, message?: string): void;
181
182 /**
183 * Asserts that value is true.
184 *
185 * @type T Type of value.
186 * @param value Actual value.
187 * @param message Message to display on error.
188 */
189 isTrue<T>(value: T, message?: string): void;
190
191 /**
192 * Asserts that value is false.
193 *
194 * @type T Type of value.
195 * @param value Actual value.
196 * @param message Message to display on error.
197 */
198 isFalse<T>(value: T, message?: string): void;
199
200 /**
201 * Asserts that value is not true.
202 *
203 * @type T Type of value.
204 * @param value Actual value.
205 * @param message Message to display on error.
206 */
207 isNotTrue<T>(value: T, message?: string): void;
208
209 /**
210 * Asserts that value is not false.
211 *
212 * @type T Type of value.
213 * @param value Actual value.
214 * @param message Message to display on error.
215 */
216 isNotFalse<T>(value: T, message?: string): void;
217
218 /**
219 * Asserts that value is null.
220 *
221 * @type T Type of value.
222 * @param value Actual value.
223 * @param message Message to display on error.
224 */
225 isNull<T>(value: T, message?: string): void;
226
227 /**
228 * Asserts that value is not null.
229 *
230 * @type T Type of value.
231 * @param value Actual value.
232 * @param message Message to display on error.
233 */
234 isNotNull<T>(value: T, message?: string): void;
235
236 /**
237 * Asserts that value is not null.
238 *
239 * @type T Type of value.
240 * @param value Actual value.
241 * @param message Message to display on error.
242 */
243 isNaN<T>(value: T, message?: string): void;
244
245 /**
246 * Asserts that value is not null.
247 *
248 * @type T Type of value.
249 * @param value Actual value.
250 * @param message Message to display on error.
251 */
252 isNotNaN<T>(value: T, message?: string): void;
253
254 /**
255 * Asserts that the target is neither null nor undefined.
256 *
257 * @type T Type of value.
258 * @param value Actual value.
259 * @param message Message to display on error.
260 */
261 exists<T>(value: T, message?: string): void;
262
263 /**
264 * Asserts that the target is either null or undefined.
265 *
266 * @type T Type of value.
267 * @param value Actual value.
268 * @param message Message to display on error.
269 */
270 notExists<T>(value: T, message?: string): void;
271
272 /**
273 * Asserts that value is undefined.
274 *
275 * @type T Type of value.
276 * @param value Actual value.
277 * @param message Message to display on error.
278 */
279 isUndefined<T>(value: T, message?: string): void;
280
281 /**
282 * Asserts that value is not undefined.
283 *
284 * @type T Type of value.
285 * @param value Actual value.
286 * @param message Message to display on error.
287 */
288 isDefined<T>(value: T, message?: string): void;
289
290 /**
291 * Asserts that value is a function.
292 *
293 * @type T Type of value.
294 * @param value Actual value.
295 * @param message Message to display on error.
296 */
297 isFunction<T>(value: T, message?: string): void;
298
299 /**
300 * Asserts that value is not a function.
301 *
302 * @type T Type of value.
303 * @param value Actual value.
304 * @param message Message to display on error.
305 */
306 isNotFunction<T>(value: T, message?: string): void;
307
308 /**
309 * Asserts that value is an object of type 'Object'
310 * (as revealed by Object.prototype.toString).
311 *
312 * @type T Type of value.
313 * @param value Actual value.
314 * @param message Message to display on error.
315 * @remarks The assertion does not match subclassed objects.
316 */
317 isObject<T>(value: T, message?: string): void;
318
319 /**
320 * Asserts that value is not an object of type 'Object'
321 * (as revealed by Object.prototype.toString).
322 *
323 * @type T Type of value.
324 * @param value Actual value.
325 * @param message Message to display on error.
326 */
327 isNotObject<T>(value: T, message?: string): void;
328
329 /**
330 * Asserts that value is an array.
331 *
332 * @type T Type of value.
333 * @param value Actual value.
334 * @param message Message to display on error.
335 */
336 isArray<T>(value: T, message?: string): void;
337
338 /**
339 * Asserts that value is not an array.
340 *
341 * @type T Type of value.
342 * @param value Actual value.
343 * @param message Message to display on error.
344 */
345 isNotArray<T>(value: T, message?: string): void;
346
347 /**
348 * Asserts that value is a string.
349 *
350 * @type T Type of value.
351 * @param value Actual value.
352 * @param message Message to display on error.
353 */
354 isString<T>(value: T, message?: string): void;
355
356 /**
357 * Asserts that value is not a string.
358 *
359 * @type T Type of value.
360 * @param value Actual value.
361 * @param message Message to display on error.
362 */
363 isNotString<T>(value: T, message?: string): void;
364
365 /**
366 * Asserts that value is a number.
367 *
368 * @type T Type of value.
369 * @param value Actual value.
370 * @param message Message to display on error.
371 */
372 isNumber<T>(value: T, message?: string): void;
373
374 /**
375 * Asserts that value is not a number.
376 *
377 * @type T Type of value.
378 * @param value Actual value.
379 * @param message Message to display on error.
380 */
381 isNotNumber<T>(value: T, message?: string): void;
382
383 /**
384 * Asserts that value is a boolean.
385 *
386 * @type T Type of value.
387 * @param value Actual value.
388 * @param message Message to display on error.
389 */
390 isBoolean<T>(value: T, message?: string): void;
391
392 /**
393 * Asserts that value is not a boolean.
394 *
395 * @type T Type of value.
396 * @param value Actual value.
397 * @param message Message to display on error.
398 */
399 isNotBoolean<T>(value: T, message?: string): void;
400
401 /**
402 * Asserts that value's type is name, as determined by Object.prototype.toString.
403 *
404 * @type T Type of value.
405 * @param value Actual value.
406 * @param name Potential expected type name of value.
407 * @param message Message to display on error.
408 */
409 typeOf<T>(value: T, name: string, message?: string): void;
410
411 /**
412 * Asserts that value's type is not name, as determined by Object.prototype.toString.
413 *
414 * @type T Type of value.
415 * @param value Actual value.
416 * @param name Potential expected type name of value.
417 * @param message Message to display on error.
418 */
419 notTypeOf<T>(value: T, name: string, message?: string): void;
420
421 /**
422 * Asserts that value is an instance of constructor.
423 *
424 * @type T Type of value.
425 * @param value Actual value.
426 * @param constructor Potential expected contructor of value.
427 * @param message Message to display on error.
428 */
429 instanceOf<T>(value: T, constructor: Function, message?: string): void;
430
431 /**
432 * Asserts that value is not an instance of constructor.
433 *
434 * @type T Type of value.
435 * @param value Actual value.
436 * @param constructor Potential expected contructor of value.
437 * @param message Message to display on error.
438 */
439 notInstanceOf<T>(value: T, type: Function, message?: string): void;
440
441 /**
442 * Asserts that haystack includes needle.
443 *
444 * @param haystack Container string.
445 * @param needle Potential expected substring of haystack.
446 * @param message Message to display on error.
447 */
448 include(haystack: string, needle: string, message?: string): void;
449
450 /**
451 * Asserts that haystack includes needle.
452 *
453 * @type T Type of values in haystack.
454 * @param haystack Container array.
455 * @param needle Potential value contained in haystack.
456 * @param message Message to display on error.
457 */
458 include<T>(haystack: T[], needle: T, message?: string): void;
459
460 /**
461 * Asserts that haystack does not include needle.
462 *
463 * @param haystack Container string or array.
464 * @param needle Potential expected substring of haystack.
465 * @param message Message to display on error.
466 */
467 notInclude(haystack: string | any[], needle: any, message?: string): void;
468
469 /**
470 * Asserts that haystack includes needle. Can be used to assert the inclusion of a value in an array or a subset of properties in an object. Deep equality is used.
471 *
472 * @param haystack Container string.
473 * @param needle Potential expected substring of haystack.
474 * @param message Message to display on error.
475 */
476 deepInclude(haystack: string, needle: string, message?: string): void;
477
478 /**
479 * Asserts that haystack includes needle. Can be used to assert the inclusion of a value in an array or a subset of properties in an object. Deep equality is used.
480 *
481 * @param haystack
482 * @param needle
483 * @param message Message to display on error.
484 */
485 deepInclude<T>(haystack: any, needle: any, message?: string): void;
486
487 /**
488 * Asserts that haystack does not include needle. Can be used to assert the absence of a value in an array or a subset of properties in an object. Deep equality is used.
489 *
490 * @param haystack Container string or array.
491 * @param needle Potential expected substring of haystack.
492 * @param message Message to display on error.
493 */
494 notDeepInclude(haystack: string | any[], needle: any, message?: string): void;
495
496 /**
497 * Asserts that ‘haystack’ includes ‘needle’. Can be used to assert the inclusion of a subset of properties in an object.
498 *
499 * Enables the use of dot- and bracket-notation for referencing nested properties.
500 * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.Asserts that ‘haystack’ includes ‘needle’.
501 * Can be used to assert the inclusion of a subset of properties in an object.
502 * Enables the use of dot- and bracket-notation for referencing nested properties.
503 * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.
504 *
505 * @param haystack
506 * @param needle
507 * @param message Message to display on error.
508 */
509 nestedInclude(haystack: any, needle: any, message?: string): void;
510
511 /**
512 * Asserts that ‘haystack’ does not include ‘needle’. Can be used to assert the absence of a subset of properties in an object.
513 *
514 * Enables the use of dot- and bracket-notation for referencing nested properties.
515 * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.Asserts that ‘haystack’ includes ‘needle’.
516 * Can be used to assert the inclusion of a subset of properties in an object.
517 * Enables the use of dot- and bracket-notation for referencing nested properties.
518 * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.
519 *
520 * @param haystack
521 * @param needle
522 * @param message Message to display on error.
523 */
524 notNestedInclude(haystack: any, needle: any, message?: string): void;
525
526 /**
527 * Asserts that ‘haystack’ includes ‘needle’. Can be used to assert the inclusion of a subset of properties in an object while checking for deep equality
528 *
529 * Enables the use of dot- and bracket-notation for referencing nested properties.
530 * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.Asserts that ‘haystack’ includes ‘needle’.
531 * Can be used to assert the inclusion of a subset of properties in an object.
532 * Enables the use of dot- and bracket-notation for referencing nested properties.
533 * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.
534 *
535 * @param haystack
536 * @param needle
537 * @param message Message to display on error.
538 */
539 deepNestedInclude(haystack: any, needle: any, message?: string): void;
540
541 /**
542 * Asserts that ‘haystack’ does not include ‘needle’. Can be used to assert the absence of a subset of properties in an object while checking for deep equality.
543 *
544 * Enables the use of dot- and bracket-notation for referencing nested properties.
545 * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.Asserts that ‘haystack’ includes ‘needle’.
546 * Can be used to assert the inclusion of a subset of properties in an object.
547 * Enables the use of dot- and bracket-notation for referencing nested properties.
548 * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.
549 *
550 * @param haystack
551 * @param needle
552 * @param message Message to display on error.
553 */
554 notDeepNestedInclude(haystack: any, needle: any, message?: string): void;
555
556 /**
557 * Asserts that ‘haystack’ includes ‘needle’. Can be used to assert the inclusion of a subset of properties in an object while ignoring inherited properties.
558 *
559 * @param haystack
560 * @param needle
561 * @param message Message to display on error.
562 */
563 ownInclude(haystack: any, needle: any, message?: string): void;
564
565 /**
566 * Asserts that ‘haystack’ includes ‘needle’. Can be used to assert the absence of a subset of properties in an object while ignoring inherited properties.
567 *
568 * @param haystack
569 * @param needle
570 * @param message Message to display on error.
571 */
572 notOwnInclude(haystack: any, needle: any, message?: string): void;
573
574 /**
575 * Asserts that ‘haystack’ includes ‘needle’. Can be used to assert the inclusion of a subset of properties in an object while ignoring inherited properties and checking for deep
576 *
577 * @param haystack
578 * @param needle
579 * @param message Message to display on error.
580 */
581 deepOwnInclude(haystack: any, needle: any, message?: string): void;
582
583 /**
584 * Asserts that ‘haystack’ includes ‘needle’. Can be used to assert the absence of a subset of properties in an object while ignoring inherited properties and checking for deep equality.
585 *
586 * @param haystack
587 * @param needle
588 * @param message Message to display on error.
589 */
590 notDeepOwnInclude(haystack: any, needle: any, message?: string): void;
591
592 /**
593 * Asserts that value matches the regular expression regexp.
594 *
595 * @param value Actual value.
596 * @param regexp Potential match of value.
597 * @param message Message to display on error.
598 */
599 match(value: string, regexp: RegExp, message?: string): void;
600
601 /**
602 * Asserts that value does not match the regular expression regexp.
603 *
604 * @param value Actual value.
605 * @param regexp Potential match of value.
606 * @param message Message to display on error.
607 */
608 notMatch(expected: any, regexp: RegExp, message?: string): void;
609
610 /**
611 * Asserts that object has a property named by property.
612 *
613 * @type T Type of object.
614 * @param object Container object.
615 * @param property Potential contained property of object.
616 * @param message Message to display on error.
617 */
618 property<T>(object: T, property: string /* keyof T */, message?: string): void;
619
620 /**
621 * Asserts that object has a property named by property.
622 *
623 * @type T Type of object.
624 * @param object Container object.
625 * @param property Potential contained property of object.
626 * @param message Message to display on error.
627 */
628 notProperty<T>(object: T, property: string /* keyof T */, message?: string): void;
629
630 /**
631 * Asserts that object has a property named by property, which can be a string
632 * using dot- and bracket-notation for deep reference.
633 *
634 * @type T Type of object.
635 * @param object Container object.
636 * @param property Potential contained property of object.
637 * @param message Message to display on error.
638 */
639 deepProperty<T>(object: T, property: string, message?: string): void;
640
641 /**
642 * Asserts that object does not have a property named by property, which can be a
643 * string using dot- and bracket-notation for deep reference.
644 *
645 * @type T Type of object.
646 * @param object Container object.
647 * @param property Potential contained property of object.
648 * @param message Message to display on error.
649 */
650 notDeepProperty<T>(object: T, property: string, message?: string): void;
651
652 /**
653 * Asserts that object has a property named by property with value given by value.
654 *
655 * @type T Type of object.
656 * @type V Type of value.
657 * @param object Container object.
658 * @param property Potential contained property of object.
659 * @param value Potential expected property value.
660 * @param message Message to display on error.
661 */
662 propertyVal<T, V>(object: T, property: string /* keyof T */, value: V, message?: string): void;
663
664 /**
665 * Asserts that object has a property named by property with value given by value.
666 *
667 * @type T Type of object.
668 * @type V Type of value.
669 * @param object Container object.
670 * @param property Potential contained property of object.
671 * @param value Potential expected property value.
672 * @param message Message to display on error.
673 */
674 propertyNotVal<T, V>(object: T, property: string /* keyof T */, value: V, message?: string): void;
675
676 /**
677 * Asserts that object has a property named by property, which can be a string
678 * using dot- and bracket-notation for deep reference.
679 *
680 * @type T Type of object.
681 * @type V Type of value.
682 * @param object Container object.
683 * @param property Potential contained property of object.
684 * @param value Potential expected property value.
685 * @param message Message to display on error.
686 */
687 deepPropertyVal<T, V>(object: T, property: string, value: V, message?: string): void;
688
689 /**
690 * Asserts that object does not have a property named by property, which can be a
691 * string using dot- and bracket-notation for deep reference.
692 *
693 * @type T Type of object.
694 * @type V Type of value.
695 * @param object Container object.
696 * @param property Potential contained property of object.
697 * @param value Potential expected property value.
698 * @param message Message to display on error.
699 */
700 deepPropertyNotVal<T, V>(object: T, property: string, value: V, message?: string): void;
701
702 /**
703 * Asserts that object has a length property with the expected value.
704 *
705 * @type T Type of object.
706 * @param object Container object.
707 * @param length Potential expected length of object.
708 * @param message Message to display on error.
709 */
710 lengthOf<T extends { readonly length?: number }>(object: T, length: number, message?: string): void;
711
712 /**
713 * Asserts that fn will throw an error.
714 *
715 * @param fn Function that may throw.
716 * @param message Message to display on error.
717 */
718 throw(fn: Function, message?: string): void;
719
720 /**
721 * Asserts that function will throw an error with message matching regexp.
722 *
723 * @param fn Function that may throw.
724 * @param regExp Potential expected message match.
725 * @param message Message to display on error.
726 */
727 throw(fn: Function, regExp: RegExp): void;
728
729 /**
730 * Asserts that function will throw an error that is an instance of constructor.
731 *
732 * @param fn Function that may throw.
733 * @param constructor Potential expected error constructor.
734 * @param message Message to display on error.
735 */
736 throw(fn: Function, constructor: Function, message?: string): void;
737
738 /**
739 * Asserts that function will throw an error that is an instance of constructor
740 * and an error with message matching regexp.
741 *
742 * @param fn Function that may throw.
743 * @param constructor Potential expected error constructor.
744 * @param message Message to display on error.
745 */
746 throw(fn: Function, constructor: Function, regExp: RegExp): void;
747
748 /**
749 * Asserts that fn will throw an error.
750 *
751 * @param fn Function that may throw.
752 * @param message Message to display on error.
753 */
754 throws(fn: Function, message?: string): void;
755
756 /**
757 * Asserts that function will throw an error with message matching regexp.
758 *
759 * @param fn Function that may throw.
760 * @param errType Potential expected message match or error constructor.
761 * @param message Message to display on error.
762 */
763 throws(fn: Function, errType: RegExp|Function, message?: string): void;
764
765 /**
766 * Asserts that function will throw an error that is an instance of constructor
767 * and an error with message matching regexp.
768 *
769 * @param fn Function that may throw.
770 * @param constructor Potential expected error constructor.
771 * @param message Message to display on error.
772 */
773 throws(fn: Function, errType: Function, regExp: RegExp): void;
774
775 /**
776 * Asserts that fn will throw an error.
777 *
778 * @param fn Function that may throw.
779 * @param message Message to display on error.
780 */
781 Throw(fn: Function, message?: string): void;
782
783 /**
784 * Asserts that function will throw an error with message matching regexp.
785 *
786 * @param fn Function that may throw.
787 * @param regExp Potential expected message match.
788 * @param message Message to display on error.
789 */
790 Throw(fn: Function, regExp: RegExp): void;
791
792 /**
793 * Asserts that function will throw an error that is an instance of constructor.
794 *
795 * @param fn Function that may throw.
796 * @param constructor Potential expected error constructor.
797 * @param message Message to display on error.
798 */
799 Throw(fn: Function, errType: Function, message?: string): void;
800
801 /**
802 * Asserts that function will throw an error that is an instance of constructor
803 * and an error with message matching regexp.
804 *
805 * @param fn Function that may throw.
806 * @param constructor Potential expected error constructor.
807 * @param message Message to display on error.
808 */
809 Throw(fn: Function, errType: Function, regExp: RegExp): void;
810
811 /**
812 * Asserts that fn will not throw an error.
813 *
814 * @param fn Function that may throw.
815 * @param message Message to display on error.
816 */
817 doesNotThrow(fn: Function, message?: string): void;
818
819 /**
820 * Asserts that function will throw an error with message matching regexp.
821 *
822 * @param fn Function that may throw.
823 * @param regExp Potential expected message match.
824 * @param message Message to display on error.
825 */
826 doesNotThrow(fn: Function, regExp: RegExp): void;
827
828 /**
829 * Asserts that function will throw an error that is an instance of constructor.
830 *
831 * @param fn Function that may throw.
832 * @param constructor Potential expected error constructor.
833 * @param message Message to display on error.
834 */
835 doesNotThrow(fn: Function, errType: Function, message?: string): void;
836
837 /**
838 * Asserts that function will throw an error that is an instance of constructor
839 * and an error with message matching regexp.
840 *
841 * @param fn Function that may throw.
842 * @param constructor Potential expected error constructor.
843 * @param message Message to display on error.
844 */
845 doesNotThrow(fn: Function, errType: Function, regExp: RegExp): void;
846
847 /**
848 * Compares two values using operator.
849 *
850 * @param val1 Left value during comparison.
851 * @param operator Comparison operator.
852 * @param val2 Right value during comparison.
853 * @param message Message to display on error.
854 */
855 operator(val1: OperatorComparable, operator: Operator, val2: OperatorComparable, message?: string): void;
856
857 /**
858 * Asserts that the target is equal to expected, to within a +/- delta range.
859 *
860 * @param actual Actual value
861 * @param expected Potential expected value.
862 * @param delta Maximum differenced between values.
863 * @param message Message to display on error.
864 */
865 closeTo(actual: number, expected: number, delta: number, message?: string): void;
866
867 /**
868 * Asserts that the target is equal to expected, to within a +/- delta range.
869 *
870 * @param actual Actual value
871 * @param expected Potential expected value.
872 * @param delta Maximum differenced between values.
873 * @param message Message to display on error.
874 */
875 approximately(act: number, exp: number, delta: number, message?: string): void;
876
877 /**
878 * Asserts that set1 and set2 have the same members. Order is not take into account.
879 *
880 * @type T Type of set values.
881 * @param set1 Actual set of values.
882 * @param set2 Potential expected set of values.
883 * @param message Message to display on error.
884 */
885 sameMembers<T>(set1: T[], set2: T[], message?: string): void;
886
887 /**
888 * Asserts that set1 and set2 have the same members using deep equality checking.
889 * Order is not take into account.
890 *
891 * @type T Type of set values.
892 * @param set1 Actual set of values.
893 * @param set2 Potential expected set of values.
894 * @param message Message to display on error.
895 */
896 sameDeepMembers<T>(set1: T[], set2: T[], message?: string): void;
897
898 /**
899 * Asserts that set1 and set2 have the same members in the same order.
900 * Uses a strict equality check (===).
901 *
902 * @type T Type of set values.
903 * @param set1 Actual set of values.
904 * @param set2 Potential expected set of values.
905 * @param message Message to display on error.
906 */
907 sameOrderedMembers<T>(set1: T[], set2: T[], message?: string): void;
908
909 /**
910 * Asserts that set1 and set2 don’t have the same members in the same order.
911 * Uses a strict equality check (===).
912 *
913 * @type T Type of set values.
914 * @param set1 Actual set of values.
915 * @param set2 Potential expected set of values.
916 * @param message Message to display on error.
917 */
918 notSameOrderedMembers<T>(set1: T[], set2: T[], message?: string): void;
919
920 /**
921 * Asserts that set1 and set2 have the same members in the same order.
922 * Uses a deep equality check.
923 *
924 * @type T Type of set values.
925 * @param set1 Actual set of values.
926 * @param set2 Potential expected set of values.
927 * @param message Message to display on error.
928 */
929 sameDeepOrderedMembers<T>(set1: T[], set2: T[], message?: string): void;
930
931 /**
932 * Asserts that set1 and set2 don’t have the same members in the same order.
933 * Uses a deep equality check.
934 *
935 * @type T Type of set values.
936 * @param set1 Actual set of values.
937 * @param set2 Potential expected set of values.
938 * @param message Message to display on error.
939 */
940 notSameDeepOrderedMembers<T>(set1: T[], set2: T[], message?: string): void;
941
942 /**
943 * Asserts that subset is included in superset in the same order beginning with the first element in superset.
944 * Uses a strict equality check (===).
945 *
946 * @type T Type of set values.
947 * @param superset Actual set of values.
948 * @param subset Potential contained set of values.
949 * @param message Message to display on error.
950 */
951 includeOrderedMembers<T>(superset: T[], subset: T[], message?: string): void;
952
953 /**
954 * Asserts that subset isn’t included in superset in the same order beginning with the first element in superset.
955 * Uses a strict equality check (===).
956 *
957 * @type T Type of set values.
958 * @param superset Actual set of values.
959 * @param subset Potential contained set of values.
960 * @param message Message to display on error.
961 */
962 notIncludeOrderedMembers<T>(superset: T[], subset: T[], message?: string): void;
963
964 /**
965 * Asserts that subset is included in superset in the same order beginning with the first element in superset.
966 * Uses a deep equality check.
967 *
968 * @type T Type of set values.
969 * @param superset Actual set of values.
970 * @param subset Potential contained set of values.
971 * @param message Message to display on error.
972 */
973 includeDeepOrderedMembers<T>(superset: T[], subset: T[], message?: string): void;
974
975 /**
976 * Asserts that subset isn’t included in superset in the same order beginning with the first element in superset.
977 * Uses a deep equality check.
978 *
979 * @type T Type of set values.
980 * @param superset Actual set of values.
981 * @param subset Potential contained set of values.
982 * @param message Message to display on error.
983 */
984 notIncludeDeepOrderedMembers<T>(superset: T[], subset: T[], message?: string): void;
985
986 /**
987 * Asserts that subset is included in superset. Order is not take into account.
988 *
989 * @type T Type of set values.
990 * @param superset Actual set of values.
991 * @param subset Potential contained set of values.
992 * @param message Message to display on error.
993 */
994 includeMembers<T>(superset: T[], subset: T[], message?: string): void;
995
996 /**
997 * Asserts that subset is included in superset using deep equality checking.
998 * Order is not take into account.
999 *
1000 * @type T Type of set values.
1001 * @param superset Actual set of values.
1002 * @param subset Potential contained set of values.
1003 * @param message Message to display on error.
1004 */
1005 includeDeepMembers<T>(superset: T[], subset: T[], message?: string): void;
1006
1007 /**
1008 * Asserts that non-object, non-array value inList appears in the flat array list.
1009 *
1010 * @type T Type of list values.
1011 * @param inList Value expected to be in the list.
1012 * @param list List of values.
1013 * @param message Message to display on error.
1014 */
1015 oneOf<T>(inList: T, list: T[], message?: string): void;
1016
1017 /**
1018 * Asserts that a function changes the value of a property.
1019 *
1020 * @type T Type of object.
1021 * @param modifier Function to run.
1022 * @param object Container object.
1023 * @param property Property of object expected to be modified.
1024 * @param message Message to display on error.
1025 */
1026 changes<T>(modifier: Function, object: T, property: string /* keyof T */, message?: string): void;
1027
1028 /**
1029 * Asserts that a function does not change the value of a property.
1030 *
1031 * @type T Type of object.
1032 * @param modifier Function to run.
1033 * @param object Container object.
1034 * @param property Property of object expected not to be modified.
1035 * @param message Message to display on error.
1036 */
1037 doesNotChange<T>(modifier: Function, object: T, property: string /* keyof T */, message?: string): void;
1038
1039 /**
1040 * Asserts that a function increases an object property.
1041 *
1042 * @type T Type of object.
1043 * @param modifier Function to run.
1044 * @param object Container object.
1045 * @param property Property of object expected to be increased.
1046 * @param message Message to display on error.
1047 */
1048 increases<T>(modifier: Function, object: T, property: string /* keyof T */, message?: string): void;
1049
1050 /**
1051 * Asserts that a function does not increase an object property.
1052 *
1053 * @type T Type of object.
1054 * @param modifier Function to run.
1055 * @param object Container object.
1056 * @param property Property of object expected not to be increased.
1057 * @param message Message to display on error.
1058 */
1059 doesNotIncrease<T>(modifier: Function, object: T, property: string /* keyof T */, message?: string): void;
1060
1061 /**
1062 * Asserts that a function decreases an object property.
1063 *
1064 * @type T Type of object.
1065 * @param modifier Function to run.
1066 * @param object Container object.
1067 * @param property Property of object expected to be decreased.
1068 * @param message Message to display on error.
1069 */
1070 decreases<T>(modifier: Function, object: T, property: string /* keyof T */, message?: string): void;
1071
1072 /**
1073 * Asserts that a function does not decrease an object property.
1074 *
1075 * @type T Type of object.
1076 * @param modifier Function to run.
1077 * @param object Container object.
1078 * @param property Property of object expected not to be decreased.
1079 * @param message Message to display on error.
1080 */
1081 doesNotDecrease<T>(modifier: Function, object: T, property: string /* keyof T */, message?: string): void;
1082
1083 /**
1084 * Asserts if value is not a false value, and throws if it is a true value.
1085 *
1086 * @type T Type of object.
1087 * @param object Actual value.
1088 * @param message Message to display on error.
1089 * @remarks This is added to allow for chai to be a drop-in replacement for
1090 * Node’s assert class.
1091 */
1092 ifError<T>(object: T, message?: string): void;
1093
1094 /**
1095 * Asserts that object is extensible (can have new properties added to it).
1096 *
1097 * @type T Type of object
1098 * @param object Actual value.
1099 * @param message Message to display on error.
1100 */
1101 isExtensible<T>(object: T, message?: string): void;
1102
1103 /**
1104 * Asserts that object is extensible (can have new properties added to it).
1105 *
1106 * @type T Type of object
1107 * @param object Actual value.
1108 * @param message Message to display on error.
1109 */
1110 extensible<T>(object: T, message?: string): void;
1111
1112 /**
1113 * Asserts that object is not extensible.
1114 *
1115 * @type T Type of object
1116 * @param object Actual value.
1117 * @param message Message to display on error.
1118 */
1119 isNotExtensible<T>(object: T, message?: string): void;
1120
1121 /**
1122 * Asserts that object is not extensible.
1123 *
1124 * @type T Type of object
1125 * @param object Actual value.
1126 * @param message Message to display on error.
1127 */
1128 notExtensible<T>(object: T, message?: string): void;
1129
1130 /**
1131 * Asserts that object is sealed (can have new properties added to it
1132 * and its existing properties cannot be removed).
1133 *
1134 * @type T Type of object
1135 * @param object Actual value.
1136 * @param message Message to display on error.
1137 */
1138 isSealed<T>(object: T, message?: string): void;
1139
1140 /**
1141 * Asserts that object is sealed (can have new properties added to it
1142 * and its existing properties cannot be removed).
1143 *
1144 * @type T Type of object
1145 * @param object Actual value.
1146 * @param message Message to display on error.
1147 */
1148 sealed<T>(object: T, message?: string): void;
1149
1150 /**
1151 * Asserts that object is not sealed.
1152 *
1153 * @type T Type of object
1154 * @param object Actual value.
1155 * @param message Message to display on error.
1156 */
1157 isNotSealed<T>(object: T, message?: string): void;
1158
1159 /**
1160 * Asserts that object is not sealed.
1161 *
1162 * @type T Type of object
1163 * @param object Actual value.
1164 * @param message Message to display on error.
1165 */
1166 notSealed<T>(object: T, message?: string): void;
1167
1168 /**
1169 * Asserts that object is frozen (cannot have new properties added to it
1170 * and its existing properties cannot be removed).
1171 *
1172 * @type T Type of object
1173 * @param object Actual value.
1174 * @param message Message to display on error.
1175 */
1176 isFrozen<T>(object: T, message?: string): void;
1177
1178 /**
1179 * Asserts that object is frozen (cannot have new properties added to it
1180 * and its existing properties cannot be removed).
1181 *
1182 * @type T Type of object
1183 * @param object Actual value.
1184 * @param message Message to display on error.
1185 */
1186 frozen<T>(object: T, message?: string): void;
1187
1188 /**
1189 * Asserts that object is not frozen (cannot have new properties added to it
1190 * and its existing properties cannot be removed).
1191 *
1192 * @type T Type of object
1193 * @param object Actual value.
1194 * @param message Message to display on error.
1195 */
1196 isNotFrozen<T>(object: T, message?: string): void;
1197
1198 /**
1199 * Asserts that object is not frozen (cannot have new properties added to it
1200 * and its existing properties cannot be removed).
1201 *
1202 * @type T Type of object
1203 * @param object Actual value.
1204 * @param message Message to display on error.
1205 */
1206 notFrozen<T>(object: T, message?: string): void;
1207
1208 /**
1209 * Asserts that the target does not contain any values. For arrays and
1210 * strings, it checks the length property. For Map and Set instances, it
1211 * checks the size property. For non-function objects, it gets the count
1212 * of own enumerable string keys.
1213 *
1214 * @type T Type of object
1215 * @param object Actual value.
1216 * @param message Message to display on error.
1217 */
1218 isEmpty<T>(object: T, message?: string): void;
1219
1220 /**
1221 * Asserts that the target contains values. For arrays and strings, it checks
1222 * the length property. For Map and Set instances, it checks the size property.
1223 * For non-function objects, it gets the count of own enumerable string keys.
1224 *
1225 * @type T Type of object.
1226 * @param object Object to test.
1227 * @param message Message to display on error.
1228 */
1229 isNotEmpty<T>(object: T, message?: string): void;
1230
1231 /**
1232 * Asserts that `object` has at least one of the `keys` provided.
1233 * You can also provide a single object instead of a `keys` array and its keys
1234 * will be used as the expected set of keys.
1235 *
1236 * @type T Type of object.
1237 * @param object Object to test.
1238 * @param keys Keys to check
1239 * @param message Message to display on error.
1240 */
1241 hasAnyKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
1242
1243 /**
1244 * Asserts that `object` has all and only all of the `keys` provided.
1245 * You can also provide a single object instead of a `keys` array and its keys
1246 * will be used as the expected set of keys.
1247 *
1248 * @type T Type of object.
1249 * @param object Object to test.
1250 * @param keys Keys to check
1251 * @param message Message to display on error.
1252 */
1253 hasAllKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
1254
1255 /**
1256 * Asserts that `object` has all of the `keys` provided but may have more keys not listed.
1257 * You can also provide a single object instead of a `keys` array and its keys
1258 * will be used as the expected set of keys.
1259 *
1260 * @type T Type of object.
1261 * @param object Object to test.
1262 * @param keys Keys to check
1263 * @param message Message to display on error.
1264 */
1265 containsAllKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
1266
1267 /**
1268 * Asserts that `object` has none of the `keys` provided.
1269 * You can also provide a single object instead of a `keys` array and its keys
1270 * will be used as the expected set of keys.
1271 *
1272 * @type T Type of object.
1273 * @param object Object to test.
1274 * @param keys Keys to check
1275 * @param message Message to display on error.
1276 */
1277 doesNotHaveAnyKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
1278
1279 /**
1280 * Asserts that `object` does not have at least one of the `keys` provided.
1281 * You can also provide a single object instead of a `keys` array and its keys
1282 * will be used as the expected set of keys.
1283 *
1284 * @type T Type of object.
1285 * @param object Object to test.
1286 * @param keys Keys to check
1287 * @param message Message to display on error.
1288 */
1289 doesNotHaveAllKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
1290
1291 /**
1292 * Asserts that `object` has at least one of the `keys` provided.
1293 * Since Sets and Maps can have objects as keys you can use this assertion to perform
1294 * a deep comparison.
1295 * You can also provide a single object instead of a `keys` array and its keys
1296 * will be used as the expected set of keys.
1297 *
1298 * @type T Type of object.
1299 * @param object Object to test.
1300 * @param keys Keys to check
1301 * @param message Message to display on error.
1302 */
1303 hasAnyDeepKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
1304
1305 /**
1306 * Asserts that `object` has all and only all of the `keys` provided.
1307 * Since Sets and Maps can have objects as keys you can use this assertion to perform
1308 * a deep comparison.
1309 * You can also provide a single object instead of a `keys` array and its keys
1310 * will be used as the expected set of keys.
1311 *
1312 * @type T Type of object.
1313 * @param object Object to test.
1314 * @param keys Keys to check
1315 * @param message Message to display on error.
1316 */
1317 hasAllDeepKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
1318
1319 /**
1320 * Asserts that `object` contains all of the `keys` provided.
1321 * Since Sets and Maps can have objects as keys you can use this assertion to perform
1322 * a deep comparison.
1323 * You can also provide a single object instead of a `keys` array and its keys
1324 * will be used as the expected set of keys.
1325 *
1326 * @type T Type of object.
1327 * @param object Object to test.
1328 * @param keys Keys to check
1329 * @param message Message to display on error.
1330 */
1331 containsAllDeepKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
1332
1333 /**
1334 * Asserts that `object` contains all of the `keys` provided.
1335 * Since Sets and Maps can have objects as keys you can use this assertion to perform
1336 * a deep comparison.
1337 * You can also provide a single object instead of a `keys` array and its keys
1338 * will be used as the expected set of keys.
1339 *
1340 * @type T Type of object.
1341 * @param object Object to test.
1342 * @param keys Keys to check
1343 * @param message Message to display on error.
1344 */
1345 doesNotHaveAnyDeepKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
1346
1347 /**
1348 * Asserts that `object` contains all of the `keys` provided.
1349 * Since Sets and Maps can have objects as keys you can use this assertion to perform
1350 * a deep comparison.
1351 * You can also provide a single object instead of a `keys` array and its keys
1352 * will be used as the expected set of keys.
1353 *
1354 * @type T Type of object.
1355 * @param object Object to test.
1356 * @param keys Keys to check
1357 * @param message Message to display on error.
1358 */
1359 doesNotHaveAllDeepKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
1360
1361 /**
1362 * Asserts that object has a direct or inherited property named by property,
1363 * which can be a string using dot- and bracket-notation for nested reference.
1364 *
1365 * @type T Type of object.
1366 * @param object Object to test.
1367 * @param property Property to test.
1368 * @param message Message to display on error.
1369 */
1370 nestedProperty<T>(object: T, property: string, message?: string): void;
1371
1372 /**
1373 * Asserts that object does not have a property named by property,
1374 * which can be a string using dot- and bracket-notation for nested reference.
1375 * The property cannot exist on the object nor anywhere in its prototype chain.
1376 *
1377 * @type T Type of object.
1378 * @param object Object to test.
1379 * @param property Property to test.
1380 * @param message Message to display on error.
1381 */
1382 notNestedProperty<T>(object: T, property: string, message?: string): void;
1383
1384 /**
1385 * Asserts that object has a property named by property with value given by value.
1386 * property can use dot- and bracket-notation for nested reference. Uses a strict equality check (===).
1387 *
1388 * @type T Type of object.
1389 * @param object Object to test.
1390 * @param property Property to test.
1391 * @param value Value to test.
1392 * @param message Message to display on error.
1393 */
1394 nestedPropertyVal<T>(object: T, property: string, value: any, message?: string): void;
1395
1396 /**
1397 * Asserts that object does not have a property named by property with value given by value.
1398 * property can use dot- and bracket-notation for nested reference. Uses a strict equality check (===).
1399 *
1400 * @type T Type of object.
1401 * @param object Object to test.
1402 * @param property Property to test.
1403 * @param value Value to test.
1404 * @param message Message to display on error.
1405 */
1406 notNestedPropertyVal<T>(object: T, property: string, value: any, message?: string): void;
1407
1408 /**
1409 * Asserts that object has a property named by property with a value given by value.
1410 * property can use dot- and bracket-notation for nested reference. Uses a deep equality check.
1411 *
1412 * @type T Type of object.
1413 * @param object Object to test.
1414 * @param property Property to test.
1415 * @param value Value to test.
1416 * @param message Message to display on error.
1417 */
1418 deepNestedPropertyVal<T>(object: T, property: string, value: any, message?: string): void;
1419
1420 /**
1421 * Asserts that object does not have a property named by property with value given by value.
1422 * property can use dot- and bracket-notation for nested reference. Uses a deep equality check.
1423 *
1424 * @type T Type of object.
1425 * @param object Object to test.
1426 * @param property Property to test.
1427 * @param value Value to test.
1428 * @param message Message to display on error.
1429 */
1430 notDeepNestedPropertyVal<T>(object: T, property: string, value: any, message?: string): void;
1431
1432 run(): void;
1433}