1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | declare namespace Chai {
|
15 | interface ChaiStatic {
|
16 | expect: ExpectStatic;
|
17 | should(): Should;
|
18 | |
19 |
|
20 |
|
21 | use(fn: (chai: any, utils: any) => void): ChaiStatic;
|
22 | assert: AssertStatic;
|
23 | config: Config;
|
24 | AssertionError: typeof AssertionError;
|
25 | version: string;
|
26 | }
|
27 |
|
28 | export interface ExpectStatic extends AssertionStatic {
|
29 | fail(actual?: any, expected?: any, message?: string, operator?: Operator): void;
|
30 | }
|
31 |
|
32 | export interface AssertStatic extends Assert {}
|
33 |
|
34 | type AssertionStatic = (target: any, message?: string) => Assertion;
|
35 |
|
36 | export type Operator = string;
|
37 |
|
38 | export type OperatorComparable = boolean | null | number | string | undefined | Date;
|
39 |
|
40 | interface ShouldAssertion {
|
41 | equal(value1: any, value2: any, message?: string): void;
|
42 | Throw: ShouldThrow;
|
43 | throw: ShouldThrow;
|
44 | exist(value: any, message?: string): void;
|
45 | }
|
46 |
|
47 | interface Should extends ShouldAssertion {
|
48 | not: ShouldAssertion;
|
49 | fail(actual: any, expected: any, message?: string, operator?: Operator): void;
|
50 | }
|
51 |
|
52 | interface ShouldThrow {
|
53 | (actual: Function): void;
|
54 | (actual: Function, expected: string | RegExp, message?: string): void;
|
55 | (actual: Function, constructor: Error | Function, expected?: string | RegExp, message?: string): void;
|
56 | }
|
57 |
|
58 | interface Assertion extends LanguageChains, NumericComparison, TypeComparison {
|
59 | not: Assertion;
|
60 | deep: Deep;
|
61 | nested: Nested;
|
62 | any: KeyFilter;
|
63 | all: KeyFilter;
|
64 | a: TypeComparison;
|
65 | an: TypeComparison;
|
66 | include: Include;
|
67 | includes: Include;
|
68 | contain: Include;
|
69 | contains: Include;
|
70 | ok: Assertion;
|
71 | true: () => Assertion;
|
72 | false: () => Assertion;
|
73 | null: () => Assertion;
|
74 | undefined: () => Assertion;
|
75 | NaN: Assertion;
|
76 | exist: Assertion;
|
77 | empty: Assertion;
|
78 | arguments: Assertion;
|
79 | Arguments: Assertion;
|
80 | equal: Equal;
|
81 | equals: Equal;
|
82 | eq: Equal;
|
83 | eql: Equal;
|
84 | eqls: Equal;
|
85 | property: Property;
|
86 | ownProperty: OwnProperty;
|
87 | haveOwnProperty: OwnProperty;
|
88 | ownPropertyDescriptor: OwnPropertyDescriptor;
|
89 | haveOwnPropertyDescriptor: OwnPropertyDescriptor;
|
90 | length: Length;
|
91 | lengthOf: Length;
|
92 | match: Match;
|
93 | matches: Match;
|
94 | string(string: string, message?: string): Assertion;
|
95 | keys: Keys;
|
96 | key(string: string): Assertion;
|
97 | throw: (message?: string) => Assertion;
|
98 | throws: Throw;
|
99 | Throw: Throw;
|
100 | respondTo: RespondTo;
|
101 | respondsTo: RespondTo;
|
102 | itself: Assertion;
|
103 | satisfy: Satisfy;
|
104 | satisfies: Satisfy;
|
105 | closeTo: CloseTo;
|
106 | approximately: CloseTo;
|
107 | members: Members;
|
108 | increase: PropertyChange;
|
109 | increases: PropertyChange;
|
110 | decrease: PropertyChange;
|
111 | decreases: PropertyChange;
|
112 | change: PropertyChange;
|
113 | changes: PropertyChange;
|
114 | extensible: Assertion;
|
115 | sealed: Assertion;
|
116 | frozen: Assertion;
|
117 | bignumber: Assertion;
|
118 |
|
119 | eventually: PromisedAssertion;
|
120 | oneOf(list: any[], message?: string): Assertion;
|
121 | }
|
122 |
|
123 | interface LanguageChains {
|
124 | to: Assertion;
|
125 | be: Assertion;
|
126 | been: Assertion;
|
127 | is: Assertion;
|
128 | that: Assertion;
|
129 | which: Assertion;
|
130 | and: Assertion;
|
131 | has: Assertion;
|
132 | have: Assertion;
|
133 | with: Assertion;
|
134 | at: Assertion;
|
135 | of: Assertion;
|
136 | same: Assertion;
|
137 | }
|
138 |
|
139 | interface NumericComparison {
|
140 | above: NumberComparer;
|
141 | gt: NumberComparer;
|
142 | greaterThan: NumberComparer;
|
143 | least: NumberComparer;
|
144 | gte: NumberComparer;
|
145 | below: NumberComparer;
|
146 | lt: NumberComparer;
|
147 | lessThan: NumberComparer;
|
148 | most: NumberComparer;
|
149 | lte: NumberComparer;
|
150 | within(start: number, finish: number, message?: string): Assertion;
|
151 | }
|
152 |
|
153 | interface NumberComparer {
|
154 | (value: number | object, message?: string): Assertion;
|
155 | }
|
156 |
|
157 | interface TypeComparison {
|
158 | (type: string, message?: string): Assertion;
|
159 | instanceof: InstanceOf;
|
160 | instanceOf: InstanceOf;
|
161 | }
|
162 |
|
163 | interface InstanceOf {
|
164 | (constructor: Object, message?: string): Assertion;
|
165 | }
|
166 |
|
167 | interface CloseTo {
|
168 | (expected: number, delta: number, message?: string): Assertion;
|
169 | }
|
170 |
|
171 | interface Nested {
|
172 | include: Include;
|
173 | property: Property;
|
174 | members: Members;
|
175 | }
|
176 |
|
177 | interface Deep {
|
178 | equal: Equal;
|
179 | equals: Equal;
|
180 | eq: Equal;
|
181 | include: Include;
|
182 | property: Property;
|
183 | members: Members;
|
184 | }
|
185 |
|
186 | interface KeyFilter {
|
187 | keys: Keys;
|
188 | }
|
189 |
|
190 | interface Equal {
|
191 | (value: any, message?: string): Assertion;
|
192 | }
|
193 |
|
194 | interface Property {
|
195 | (name: string, value?: any, message?: string): Assertion;
|
196 | }
|
197 |
|
198 | interface OwnProperty {
|
199 | (name: string, message?: string): Assertion;
|
200 | }
|
201 |
|
202 | interface OwnPropertyDescriptor {
|
203 | (name: string, descriptor: PropertyDescriptor, message?: string): Assertion;
|
204 | (name: string, message?: string): Assertion;
|
205 | }
|
206 |
|
207 | interface Length extends LanguageChains, NumericComparison {
|
208 | (length: number, message?: string): Assertion;
|
209 | }
|
210 |
|
211 | interface Include {
|
212 | (value: Object | string | number, message?: string): Assertion;
|
213 | keys: Keys;
|
214 | members: Members;
|
215 | any: KeyFilter;
|
216 | all: KeyFilter;
|
217 | }
|
218 |
|
219 | interface Match {
|
220 | (regexp: RegExp | string, message?: string): Assertion;
|
221 | }
|
222 |
|
223 | interface Keys {
|
224 | (...keys: string[]): Assertion;
|
225 | (keys: any[]): Assertion;
|
226 | (keys: Object): Assertion;
|
227 | }
|
228 |
|
229 | interface Throw {
|
230 | (): Assertion;
|
231 | (expected: string, message?: string): Assertion;
|
232 | (expected: RegExp, message?: string): Assertion;
|
233 | (constructor: Error, expected?: string, message?: string): Assertion;
|
234 | (constructor: Error, expected?: RegExp, message?: string): Assertion;
|
235 | (constructor: Function, expected?: string, message?: string): Assertion;
|
236 | (constructor: Function, expected?: RegExp, message?: string): Assertion;
|
237 | }
|
238 |
|
239 | interface RespondTo {
|
240 | (method: string, message?: string): Assertion;
|
241 | }
|
242 |
|
243 | interface Satisfy {
|
244 | (matcher: Function, message?: string): Assertion;
|
245 | }
|
246 |
|
247 | interface Members {
|
248 | (set: any[], message?: string): Assertion;
|
249 | }
|
250 |
|
251 | interface PropertyChange {
|
252 | (object: Object, property: string, message?: string): Assertion;
|
253 | }
|
254 |
|
255 | export interface Assert {
|
256 | |
257 |
|
258 |
|
259 |
|
260 | (expression: any, message?: string): void;
|
261 |
|
262 | |
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 | fail<T>(actual?: T, expected?: T, message?: string, operator?: Operator): void;
|
273 |
|
274 | |
275 |
|
276 |
|
277 |
|
278 |
|
279 |
|
280 |
|
281 | isOk<T>(value: T, message?: string): void;
|
282 |
|
283 | |
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 | ok<T>(value: T, message?: string): void;
|
291 |
|
292 | |
293 |
|
294 |
|
295 |
|
296 |
|
297 |
|
298 |
|
299 | isNotOk<T>(value: T, message?: string): void;
|
300 |
|
301 | |
302 |
|
303 |
|
304 |
|
305 |
|
306 |
|
307 |
|
308 | notOk<T>(value: T, message?: string): void;
|
309 |
|
310 | |
311 |
|
312 |
|
313 |
|
314 |
|
315 |
|
316 |
|
317 |
|
318 | equal<T>(actual: T, expected: T, message?: string): void;
|
319 |
|
320 | |
321 |
|
322 |
|
323 |
|
324 |
|
325 |
|
326 |
|
327 |
|
328 | notEqual<T>(actual: T, expected: T, message?: string): void;
|
329 |
|
330 | |
331 |
|
332 |
|
333 |
|
334 |
|
335 |
|
336 |
|
337 |
|
338 | strictEqual<T>(actual: T, expected: T, message?: string): void;
|
339 |
|
340 | |
341 |
|
342 |
|
343 |
|
344 |
|
345 |
|
346 |
|
347 |
|
348 | notStrictEqual<T>(actual: T, expected: T, message?: string): void;
|
349 |
|
350 | |
351 |
|
352 |
|
353 |
|
354 |
|
355 |
|
356 |
|
357 |
|
358 | deepEqual<T>(actual: T, expected: T, message?: string): void;
|
359 |
|
360 | |
361 |
|
362 |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 |
|
368 | notDeepEqual<T>(actual: T, expected: T, message?: string): void;
|
369 |
|
370 | |
371 |
|
372 |
|
373 |
|
374 |
|
375 |
|
376 |
|
377 | isAbove(valueToCheck: number, valueToBeAbove: number, message?: string): void;
|
378 |
|
379 | |
380 |
|
381 |
|
382 |
|
383 |
|
384 |
|
385 |
|
386 | isAtLeast(valueToCheck: number, valueToBeAtLeast: number, message?: string): void;
|
387 |
|
388 | |
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 |
|
395 | isBelow(valueToCheck: number, valueToBeBelow: number, message?: string): void;
|
396 |
|
397 | |
398 |
|
399 |
|
400 |
|
401 |
|
402 |
|
403 |
|
404 | isAtMost(valueToCheck: number, valueToBeAtMost: number, message?: string): void;
|
405 |
|
406 | |
407 |
|
408 |
|
409 |
|
410 |
|
411 |
|
412 |
|
413 | isTrue<T>(value: T, message?: string): void;
|
414 |
|
415 | |
416 |
|
417 |
|
418 |
|
419 |
|
420 |
|
421 |
|
422 | isFalse<T>(value: T, message?: string): void;
|
423 |
|
424 | |
425 |
|
426 |
|
427 |
|
428 |
|
429 |
|
430 |
|
431 | isNotTrue<T>(value: T, message?: string): void;
|
432 |
|
433 | |
434 |
|
435 |
|
436 |
|
437 |
|
438 |
|
439 |
|
440 | isNotFalse<T>(value: T, message?: string): void;
|
441 |
|
442 | |
443 |
|
444 |
|
445 |
|
446 |
|
447 |
|
448 |
|
449 | isNull<T>(value: T, message?: string): void;
|
450 |
|
451 | |
452 |
|
453 |
|
454 |
|
455 |
|
456 |
|
457 |
|
458 | isNotNull<T>(value: T, message?: string): void;
|
459 |
|
460 | |
461 |
|
462 |
|
463 |
|
464 |
|
465 |
|
466 |
|
467 | isNaN<T>(value: T, message?: string): void;
|
468 |
|
469 | |
470 |
|
471 |
|
472 |
|
473 |
|
474 |
|
475 |
|
476 | isNotNaN<T>(value: T, message?: string): void;
|
477 |
|
478 | |
479 |
|
480 |
|
481 |
|
482 |
|
483 |
|
484 |
|
485 | isUndefined<T>(value: T, message?: string): void;
|
486 |
|
487 | |
488 |
|
489 |
|
490 |
|
491 |
|
492 |
|
493 |
|
494 | isDefined<T>(value: T, message?: string): void;
|
495 |
|
496 | |
497 |
|
498 |
|
499 |
|
500 |
|
501 |
|
502 |
|
503 | isFunction<T>(value: T, message?: string): void;
|
504 |
|
505 | |
506 |
|
507 |
|
508 |
|
509 |
|
510 |
|
511 |
|
512 | isNotFunction<T>(value: T, message?: string): void;
|
513 |
|
514 | |
515 |
|
516 |
|
517 |
|
518 |
|
519 |
|
520 |
|
521 |
|
522 |
|
523 | isObject<T>(value: T, message?: string): void;
|
524 |
|
525 | |
526 |
|
527 |
|
528 |
|
529 |
|
530 |
|
531 |
|
532 |
|
533 | isNotObject<T>(value: T, message?: string): void;
|
534 |
|
535 | |
536 |
|
537 |
|
538 |
|
539 |
|
540 |
|
541 |
|
542 | isArray<T>(value: T, message?: string): void;
|
543 |
|
544 | |
545 |
|
546 |
|
547 |
|
548 |
|
549 |
|
550 |
|
551 | isNotArray<T>(value: T, message?: string): void;
|
552 |
|
553 | |
554 |
|
555 |
|
556 |
|
557 |
|
558 |
|
559 |
|
560 | isString<T>(value: T, message?: string): void;
|
561 |
|
562 | |
563 |
|
564 |
|
565 |
|
566 |
|
567 |
|
568 |
|
569 | isNotString<T>(value: T, message?: string): void;
|
570 |
|
571 | |
572 |
|
573 |
|
574 |
|
575 |
|
576 |
|
577 |
|
578 | isNumber<T>(value: T, message?: string): void;
|
579 |
|
580 | |
581 |
|
582 |
|
583 |
|
584 |
|
585 |
|
586 |
|
587 | isNotNumber<T>(value: T, message?: string): void;
|
588 |
|
589 | |
590 |
|
591 |
|
592 |
|
593 |
|
594 |
|
595 |
|
596 | isBoolean<T>(value: T, message?: string): void;
|
597 |
|
598 | |
599 |
|
600 |
|
601 |
|
602 |
|
603 |
|
604 |
|
605 | isNotBoolean<T>(value: T, message?: string): void;
|
606 |
|
607 | |
608 |
|
609 |
|
610 |
|
611 |
|
612 |
|
613 |
|
614 |
|
615 | typeOf<T>(value: T, name: string, message?: string): void;
|
616 |
|
617 | |
618 |
|
619 |
|
620 |
|
621 |
|
622 |
|
623 |
|
624 |
|
625 | notTypeOf<T>(value: T, name: string, message?: string): void;
|
626 |
|
627 | |
628 |
|
629 |
|
630 |
|
631 |
|
632 |
|
633 |
|
634 |
|
635 | instanceOf<T>(value: T, constructor: Function, message?: string): void;
|
636 |
|
637 | /**
|
638 | * Asserts that value is not an instance of constructor.
|
639 | *
|
640 | * @type T Type of value.
|
641 | * @param value Actual value.
|
642 | * @param constructor Potential expected contructor of value.
|
643 | * @param message Message to display on error.
|
644 | */
|
645 | notInstanceOf<T>(value: T, type: Function, message?: string): void;
|
646 |
|
647 | /**
|
648 | * Asserts that haystack includes needle.
|
649 | *
|
650 | * @param haystack Container string.
|
651 | * @param needle Potential expected substring of haystack.
|
652 | * @param message Message to display on error.
|
653 | */
|
654 | include(haystack: string, needle: string, message?: string): void;
|
655 |
|
656 | /**
|
657 | * Asserts that haystack includes needle.
|
658 | *
|
659 | * @type T Type of values in haystack.
|
660 | * @param haystack Container array.
|
661 | * @param needle Potential value contained in haystack.
|
662 | * @param message Message to display on error.
|
663 | */
|
664 | include<T>(haystack: T[], needle: T, message?: string): void;
|
665 |
|
666 | /**
|
667 | * Asserts that haystack does not include needle.
|
668 | *
|
669 | * @param haystack Container string.
|
670 | * @param needle Potential expected substring of haystack.
|
671 | * @param message Message to display on error.
|
672 | */
|
673 | notInclude(haystack: string, needle: any, message?: string): void;
|
674 |
|
675 | /**
|
676 | * Asserts that haystack does not include needle.
|
677 | *
|
678 | * @type T Type of values in haystack.
|
679 | * @param haystack Container array.
|
680 | * @param needle Potential value contained in haystack.
|
681 | * @param message Message to display on error.
|
682 | */
|
683 | notInclude(haystack: any[], needle: any, message?: string): void;
|
684 |
|
685 | /**
|
686 | * Asserts that value matches the regular expression regexp.
|
687 | *
|
688 | * @param value Actual value.
|
689 | * @param regexp Potential match of value.
|
690 | * @param message Message to display on error.
|
691 | */
|
692 | match(value: string, regexp: RegExp, message?: string): void;
|
693 |
|
694 | /**
|
695 | * Asserts that value does not match the regular expression regexp.
|
696 | *
|
697 | * @param value Actual value.
|
698 | * @param regexp Potential match of value.
|
699 | * @param message Message to display on error.
|
700 | */
|
701 | notMatch(expected: any, regexp: RegExp, message?: string): void;
|
702 |
|
703 | /**
|
704 | * Asserts that object has a property named by property.
|
705 | *
|
706 | * @type T Type of object.
|
707 | * @param object Container object.
|
708 | * @param property Potential contained property of object.
|
709 | * @param message Message to display on error.
|
710 | */
|
711 | property<T>(object: T, property: string , message?: string): void;
|
712 |
|
713 | /**
|
714 | * Asserts that object has a property named by property.
|
715 | *
|
716 | * @type T Type of object.
|
717 | * @param object Container object.
|
718 | * @param property Potential contained property of object.
|
719 | * @param message Message to display on error.
|
720 | */
|
721 | notProperty<T>(object: T, property: string , message?: string): void;
|
722 |
|
723 | /**
|
724 | * Asserts that object has a property named by property, which can be a string
|
725 | * using dot- and bracket-notation for deep reference.
|
726 | *
|
727 | * @type T Type of object.
|
728 | * @param object Container object.
|
729 | * @param property Potential contained property of object.
|
730 | * @param message Message to display on error.
|
731 | */
|
732 | deepProperty<T>(object: T, property: string, message?: string): void;
|
733 |
|
734 | /**
|
735 | * Asserts that object does not have a property named by property, which can be a
|
736 | * string using dot- and bracket-notation for deep reference.
|
737 | *
|
738 | * @type T Type of object.
|
739 | * @param object Container object.
|
740 | * @param property Potential contained property of object.
|
741 | * @param message Message to display on error.
|
742 | */
|
743 | notDeepProperty<T>(object: T, property: string, message?: string): void;
|
744 |
|
745 | /**
|
746 | * Asserts that object has a property named by property with value given by value.
|
747 | *
|
748 | * @type T Type of object.
|
749 | * @type V Type of value.
|
750 | * @param object Container object.
|
751 | * @param property Potential contained property of object.
|
752 | * @param value Potential expected property value.
|
753 | * @param message Message to display on error.
|
754 | */
|
755 | propertyVal<T, V>(object: T, property: string , value: V, message?: string): void;
|
756 |
|
757 | /**
|
758 | * Asserts that object has a property named by property with value given by value.
|
759 | *
|
760 | * @type T Type of object.
|
761 | * @type V Type of value.
|
762 | * @param object Container object.
|
763 | * @param property Potential contained property of object.
|
764 | * @param value Potential expected property value.
|
765 | * @param message Message to display on error.
|
766 | */
|
767 | propertyNotVal<T, V>(object: T, property: string , value: V, message?: string): void;
|
768 |
|
769 | /**
|
770 | * Asserts that object has a property named by property, which can be a string
|
771 | * using dot- and bracket-notation for deep reference.
|
772 | *
|
773 | * @type T Type of object.
|
774 | * @type V Type of value.
|
775 | * @param object Container object.
|
776 | * @param property Potential contained property of object.
|
777 | * @param value Potential expected property value.
|
778 | * @param message Message to display on error.
|
779 | */
|
780 | deepPropertyVal<T, V>(object: T, property: string, value: V, message?: string): void;
|
781 |
|
782 | /**
|
783 | * Asserts that object does not have a property named by property, which can be a
|
784 | * string using dot- and bracket-notation for deep reference.
|
785 | *
|
786 | * @type T Type of object.
|
787 | * @type V Type of value.
|
788 | * @param object Container object.
|
789 | * @param property Potential contained property of object.
|
790 | * @param value Potential expected property value.
|
791 | * @param message Message to display on error.
|
792 | */
|
793 | deepPropertyNotVal<T, V>(object: T, property: string, value: V, message?: string): void;
|
794 |
|
795 | /**
|
796 | * Asserts that object has a length property with the expected value.
|
797 | *
|
798 | * @type T Type of object.
|
799 | * @param object Container object.
|
800 | * @param length Potential expected length of object.
|
801 | * @param message Message to display on error.
|
802 | */
|
803 | lengthOf<T extends { readonly length?: number }>(object: T, length: number, message?: string): void;
|
804 |
|
805 | /**
|
806 | * Asserts that fn will throw an error.
|
807 | *
|
808 | * @param fn Function that may throw.
|
809 | * @param message Message to display on error.
|
810 | */
|
811 | throw(fn: Function, message?: string): void;
|
812 |
|
813 | /**
|
814 | * Asserts that function will throw an error with message matching regexp.
|
815 | *
|
816 | * @param fn Function that may throw.
|
817 | * @param regExp Potential expected message match.
|
818 | * @param message Message to display on error.
|
819 | */
|
820 | throw(fn: Function, regExp: RegExp): void;
|
821 |
|
822 | /**
|
823 | * Asserts that function will throw an error that is an instance of constructor.
|
824 | *
|
825 | * @param fn Function that may throw.
|
826 | * @param constructor Potential expected error constructor.
|
827 | * @param message Message to display on error.
|
828 | */
|
829 | throw(fn: Function, constructor: Function, message?: string): void;
|
830 |
|
831 | /**
|
832 | * Asserts that function will throw an error that is an instance of constructor
|
833 | * and an error with message matching regexp.
|
834 | *
|
835 | * @param fn Function that may throw.
|
836 | * @param constructor Potential expected error constructor.
|
837 | * @param message Message to display on error.
|
838 | */
|
839 | throw(fn: Function, constructor: Function, regExp: RegExp): void;
|
840 |
|
841 | /**
|
842 | * Asserts that fn will throw an error.
|
843 | *
|
844 | * @param fn Function that may throw.
|
845 | * @param message Message to display on error.
|
846 | */
|
847 | throws(fn: Function, message?: string): void;
|
848 |
|
849 | /**
|
850 | * Asserts that function will throw an error with message matching regexp.
|
851 | *
|
852 | * @param fn Function that may throw.
|
853 | * @param regExp Potential expected message match.
|
854 | * @param message Message to display on error.
|
855 | */
|
856 | throws(fn: Function, regExp: RegExp, message?: string): void;
|
857 |
|
858 | /**
|
859 | * Asserts that function will throw an error that is an instance of constructor.
|
860 | *
|
861 | * @param fn Function that may throw.
|
862 | * @param constructor Potential expected error constructor.
|
863 | * @param message Message to display on error.
|
864 | */
|
865 | throws(fn: Function, errType: Function, message?: string): void;
|
866 |
|
867 | /**
|
868 | * Asserts that function will throw an error that is an instance of constructor
|
869 | * and an error with message matching regexp.
|
870 | *
|
871 | * @param fn Function that may throw.
|
872 | * @param constructor Potential expected error constructor.
|
873 | * @param message Message to display on error.
|
874 | */
|
875 | throws(fn: Function, errType: Function, regExp: RegExp): void;
|
876 |
|
877 | /**
|
878 | * Asserts that fn will throw an error.
|
879 | *
|
880 | * @param fn Function that may throw.
|
881 | * @param message Message to display on error.
|
882 | */
|
883 | Throw(fn: Function, message?: string): void;
|
884 |
|
885 | /**
|
886 | * Asserts that function will throw an error with message matching regexp.
|
887 | *
|
888 | * @param fn Function that may throw.
|
889 | * @param regExp Potential expected message match.
|
890 | * @param message Message to display on error.
|
891 | */
|
892 | Throw(fn: Function, regExp: RegExp): void;
|
893 |
|
894 | /**
|
895 | * Asserts that function will throw an error that is an instance of constructor.
|
896 | *
|
897 | * @param fn Function that may throw.
|
898 | * @param constructor Potential expected error constructor.
|
899 | * @param message Message to display on error.
|
900 | */
|
901 | Throw(fn: Function, errType: Function, message?: string): void;
|
902 |
|
903 | /**
|
904 | * Asserts that function will throw an error that is an instance of constructor
|
905 | * and an error with message matching regexp.
|
906 | *
|
907 | * @param fn Function that may throw.
|
908 | * @param constructor Potential expected error constructor.
|
909 | * @param message Message to display on error.
|
910 | */
|
911 | Throw(fn: Function, errType: Function, regExp: RegExp): void;
|
912 |
|
913 | /**
|
914 | * Asserts that fn will not throw an error.
|
915 | *
|
916 | * @param fn Function that may throw.
|
917 | * @param message Message to display on error.
|
918 | */
|
919 | doesNotThrow(fn: Function, message?: string): void;
|
920 |
|
921 | /**
|
922 | * Asserts that function will throw an error with message matching regexp.
|
923 | *
|
924 | * @param fn Function that may throw.
|
925 | * @param regExp Potential expected message match.
|
926 | * @param message Message to display on error.
|
927 | */
|
928 | doesNotThrow(fn: Function, regExp: RegExp): void;
|
929 |
|
930 | /**
|
931 | * Asserts that function will throw an error that is an instance of constructor.
|
932 | *
|
933 | * @param fn Function that may throw.
|
934 | * @param constructor Potential expected error constructor.
|
935 | * @param message Message to display on error.
|
936 | */
|
937 | doesNotThrow(fn: Function, errType: Function, message?: string): void;
|
938 |
|
939 | /**
|
940 | * Asserts that function will throw an error that is an instance of constructor
|
941 | * and an error with message matching regexp.
|
942 | *
|
943 | * @param fn Function that may throw.
|
944 | * @param constructor Potential expected error constructor.
|
945 | * @param message Message to display on error.
|
946 | */
|
947 | doesNotThrow(fn: Function, errType: Function, regExp: RegExp): void;
|
948 |
|
949 | /**
|
950 | * Compares two values using operator.
|
951 | *
|
952 | * @param val1 Left value during comparison.
|
953 | * @param operator Comparison operator.
|
954 | * @param val2 Right value during comparison.
|
955 | * @param message Message to display on error.
|
956 | */
|
957 | operator(val1: OperatorComparable, operator: Operator, val2: OperatorComparable, message?: string): void;
|
958 |
|
959 | /**
|
960 | * Asserts that the target is equal to expected, to within a +/- delta range.
|
961 | *
|
962 | * @param actual Actual value
|
963 | * @param expected Potential expected value.
|
964 | * @param delta Maximum differenced between values.
|
965 | * @param message Message to display on error.
|
966 | */
|
967 | closeTo(actual: number, expected: number, delta: number, message?: string): void;
|
968 |
|
969 | /**
|
970 | * Asserts that the target is equal to expected, to within a +/- delta range.
|
971 | *
|
972 | * @param actual Actual value
|
973 | * @param expected Potential expected value.
|
974 | * @param delta Maximum differenced between values.
|
975 | * @param message Message to display on error.
|
976 | */
|
977 | approximately(act: number, exp: number, delta: number, message?: string): void;
|
978 |
|
979 | /**
|
980 | * Asserts that set1 and set2 have the same members. Order is not take into account.
|
981 | *
|
982 | * @type T Type of set values.
|
983 | * @param set1 Actual set of values.
|
984 | * @param set2 Potential expected set of values.
|
985 | * @param message Message to display on error.
|
986 | */
|
987 | sameMembers<T>(set1: T[], set2: T[], message?: string): void;
|
988 |
|
989 | /**
|
990 | * Asserts that set1 and set2 have the same members using deep equality checking.
|
991 | * Order is not take into account.
|
992 | *
|
993 | * @type T Type of set values.
|
994 | * @param set1 Actual set of values.
|
995 | * @param set2 Potential expected set of values.
|
996 | * @param message Message to display on error.
|
997 | */
|
998 | sameDeepMembers<T>(set1: T[], set2: T[], message?: string): void;
|
999 |
|
1000 | /**
|
1001 | * Asserts that subset is included in superset. Order is not take into account.
|
1002 | *
|
1003 | * @type T Type of set values.
|
1004 | * @param superset Actual set of values.
|
1005 | * @param subset Potential contained set of values.
|
1006 | * @param message Message to display on error.
|
1007 | */
|
1008 | includeMembers<T>(superset: T[], subset: T[], message?: string): void;
|
1009 |
|
1010 | /**
|
1011 | * Asserts that subset is included in superset using deep equality checking.
|
1012 | * Order is not take into account.
|
1013 | *
|
1014 | * @type T Type of set values.
|
1015 | * @param superset Actual set of values.
|
1016 | * @param subset Potential contained set of values.
|
1017 | * @param message Message to display on error.
|
1018 | */
|
1019 | includeDeepMembers<T>(superset: T[], subset: T[], message?: string): void;
|
1020 |
|
1021 | /**
|
1022 | * Asserts that non-object, non-array value inList appears in the flat array list.
|
1023 | *
|
1024 | * @type T Type of list values.
|
1025 | * @param inList Value expected to be in the list.
|
1026 | * @param list List of values.
|
1027 | * @param message Message to display on error.
|
1028 | */
|
1029 | oneOf<T>(inList: T, list: T[], message?: string): void;
|
1030 |
|
1031 | /**
|
1032 | * Asserts that a function changes the value of a property.
|
1033 | *
|
1034 | * @type T Type of object.
|
1035 | * @param modifier Function to run.
|
1036 | * @param object Container object.
|
1037 | * @param property Property of object expected to be modified.
|
1038 | * @param message Message to display on error.
|
1039 | */
|
1040 | changes<T>(modifier: Function, object: T, property: string , message?: string): void;
|
1041 |
|
1042 | /**
|
1043 | * Asserts that a function does not change the value of a property.
|
1044 | *
|
1045 | * @type T Type of object.
|
1046 | * @param modifier Function to run.
|
1047 | * @param object Container object.
|
1048 | * @param property Property of object expected not to be modified.
|
1049 | * @param message Message to display on error.
|
1050 | */
|
1051 | doesNotChange<T>(modifier: Function, object: T, property: string , message?: string): void;
|
1052 |
|
1053 | /**
|
1054 | * Asserts that a function increases an object property.
|
1055 | *
|
1056 | * @type T Type of object.
|
1057 | * @param modifier Function to run.
|
1058 | * @param object Container object.
|
1059 | * @param property Property of object expected to be increased.
|
1060 | * @param message Message to display on error.
|
1061 | */
|
1062 | increases<T>(modifier: Function, object: T, property: string , message?: string): void;
|
1063 |
|
1064 | /**
|
1065 | * Asserts that a function does not increase an object property.
|
1066 | *
|
1067 | * @type T Type of object.
|
1068 | * @param modifier Function to run.
|
1069 | * @param object Container object.
|
1070 | * @param property Property of object expected not to be increased.
|
1071 | * @param message Message to display on error.
|
1072 | */
|
1073 | doesNotIncrease<T>(modifier: Function, object: T, property: string , message?: string): void;
|
1074 |
|
1075 | /**
|
1076 | * Asserts that a function decreases an object property.
|
1077 | *
|
1078 | * @type T Type of object.
|
1079 | * @param modifier Function to run.
|
1080 | * @param object Container object.
|
1081 | * @param property Property of object expected to be decreased.
|
1082 | * @param message Message to display on error.
|
1083 | */
|
1084 | decreases<T>(modifier: Function, object: T, property: string , message?: string): void;
|
1085 |
|
1086 | /**
|
1087 | * Asserts that a function does not decrease an object property.
|
1088 | *
|
1089 | * @type T Type of object.
|
1090 | * @param modifier Function to run.
|
1091 | * @param object Container object.
|
1092 | * @param property Property of object expected not to be decreased.
|
1093 | * @param message Message to display on error.
|
1094 | */
|
1095 | doesNotDecrease<T>(modifier: Function, object: T, property: string , message?: string): void;
|
1096 |
|
1097 | /**
|
1098 | * Asserts if value is not a false value, and throws if it is a true value.
|
1099 | *
|
1100 | * @type T Type of object.
|
1101 | * @param object Actual value.
|
1102 | * @param message Message to display on error.
|
1103 | * @remarks This is added to allow for chai to be a drop-in replacement for
|
1104 | * Node’s assert class.
|
1105 | */
|
1106 | ifError<T>(object: T, message?: string): void;
|
1107 |
|
1108 | /**
|
1109 | * Asserts that object is extensible (can have new properties added to it).
|
1110 | *
|
1111 | * @type T Type of object
|
1112 | * @param object Actual value.
|
1113 | * @param message Message to display on error.
|
1114 | */
|
1115 | isExtensible<T>(object: T, message?: string): void;
|
1116 |
|
1117 | /**
|
1118 | * Asserts that object is extensible (can have new properties added to it).
|
1119 | *
|
1120 | * @type T Type of object
|
1121 | * @param object Actual value.
|
1122 | * @param message Message to display on error.
|
1123 | */
|
1124 | extensible<T>(object: T, message?: string): void;
|
1125 |
|
1126 | /**
|
1127 | * Asserts that object is not extensible.
|
1128 | *
|
1129 | * @type T Type of object
|
1130 | * @param object Actual value.
|
1131 | * @param message Message to display on error.
|
1132 | */
|
1133 | isNotExtensible<T>(object: T, message?: string): void;
|
1134 |
|
1135 | /**
|
1136 | * Asserts that object is not extensible.
|
1137 | *
|
1138 | * @type T Type of object
|
1139 | * @param object Actual value.
|
1140 | * @param message Message to display on error.
|
1141 | */
|
1142 | notExtensible<T>(object: T, message?: string): void;
|
1143 |
|
1144 | /**
|
1145 | * Asserts that object is sealed (can have new properties added to it
|
1146 | * and its existing properties cannot be removed).
|
1147 | *
|
1148 | * @type T Type of object
|
1149 | * @param object Actual value.
|
1150 | * @param message Message to display on error.
|
1151 | */
|
1152 | isSealed<T>(object: T, message?: string): void;
|
1153 |
|
1154 | /**
|
1155 | * Asserts that object is sealed (can have new properties added to it
|
1156 | * and its existing properties cannot be removed).
|
1157 | *
|
1158 | * @type T Type of object
|
1159 | * @param object Actual value.
|
1160 | * @param message Message to display on error.
|
1161 | */
|
1162 | sealed<T>(object: T, message?: string): void;
|
1163 |
|
1164 | /**
|
1165 | * Asserts that object is not sealed.
|
1166 | *
|
1167 | * @type T Type of object
|
1168 | * @param object Actual value.
|
1169 | * @param message Message to display on error.
|
1170 | */
|
1171 | isNotSealed<T>(object: T, message?: string): void;
|
1172 |
|
1173 | /**
|
1174 | * Asserts that object is not sealed.
|
1175 | *
|
1176 | * @type T Type of object
|
1177 | * @param object Actual value.
|
1178 | * @param message Message to display on error.
|
1179 | */
|
1180 | notSealed<T>(object: T, message?: string): void;
|
1181 |
|
1182 | /**
|
1183 | * Asserts that object is frozen (cannot have new properties added to it
|
1184 | * and its existing properties cannot be removed).
|
1185 | *
|
1186 | * @type T Type of object
|
1187 | * @param object Actual value.
|
1188 | * @param message Message to display on error.
|
1189 | */
|
1190 | isFrozen<T>(object: T, message?: string): void;
|
1191 |
|
1192 | /**
|
1193 | * Asserts that object is frozen (cannot have new properties added to it
|
1194 | * and its existing properties cannot be removed).
|
1195 | *
|
1196 | * @type T Type of object
|
1197 | * @param object Actual value.
|
1198 | * @param message Message to display on error.
|
1199 | */
|
1200 | frozen<T>(object: T, message?: string): void;
|
1201 |
|
1202 | /**
|
1203 | * Asserts that object is not frozen (cannot have new properties added to it
|
1204 | * and its existing properties cannot be removed).
|
1205 | *
|
1206 | * @type T Type of object
|
1207 | * @param object Actual value.
|
1208 | * @param message Message to display on error.
|
1209 | */
|
1210 | isNotFrozen<T>(object: T, message?: string): void;
|
1211 |
|
1212 | /**
|
1213 | * Asserts that object is not frozen (cannot have new properties added to it
|
1214 | * and its existing properties cannot be removed).
|
1215 | *
|
1216 | * @type T Type of object
|
1217 | * @param object Actual value.
|
1218 | * @param message Message to display on error.
|
1219 | */
|
1220 | notFrozen<T>(object: T, message?: string): void;
|
1221 | }
|
1222 |
|
1223 | export interface Config {
|
1224 | /**
|
1225 | * Default: false
|
1226 | */
|
1227 | includeStack: boolean;
|
1228 |
|
1229 | /**
|
1230 | * Default: true
|
1231 | */
|
1232 | showDiff: boolean;
|
1233 |
|
1234 | /**
|
1235 | * Default: 40
|
1236 | */
|
1237 | truncateThreshold: number;
|
1238 | }
|
1239 |
|
1240 | export class AssertionError {
|
1241 | constructor(message: string, _props?: any, ssf?: Function);
|
1242 | public name: string;
|
1243 | public message: string;
|
1244 | public showDiff: boolean;
|
1245 | public stack: string;
|
1246 | }
|
1247 | }
|
1248 |
|
1249 | declare const chai: Chai.ChaiStatic;
|
1250 |
|
1251 | declare module 'chai' {
|
1252 | export = chai;
|
1253 | }
|
1254 |
|
1255 | interface Object {
|
1256 | should: Chai.Assertion;
|
1257 | }
|