1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | declare namespace Chai {
|
20 | type Message = string | (() => string);
|
21 | type ObjectProperty = string | symbol | number;
|
22 |
|
23 | interface PathInfo {
|
24 | parent: object;
|
25 | name: string;
|
26 | value?: any;
|
27 | exists: boolean;
|
28 | }
|
29 |
|
30 | interface ErrorConstructor {
|
31 | new(...args: any[]): Error;
|
32 | }
|
33 |
|
34 | interface ChaiUtils {
|
35 | addChainableMethod(
|
36 |
|
37 | ctx: object,
|
38 |
|
39 | name: string,
|
40 |
|
41 | method: (...args: any[]) => void,
|
42 |
|
43 | chainingBehavior?: () => void
|
44 | ): void;
|
45 | overwriteChainableMethod(
|
46 | ctx: object,
|
47 | name: string,
|
48 | method: (...args: any[]) => void,
|
49 | chainingBehavior?: () => void
|
50 | ): void;
|
51 | addLengthGuard(
|
52 | fn: Function,
|
53 | assertionName: string,
|
54 | isChainable: boolean
|
55 | ): void;
|
56 | addMethod(ctx: object, name: string, method: Function): void;
|
57 | addProperty(ctx: object, name: string, getter: () => any): void;
|
58 | overwriteMethod(ctx: object, name: string, method: Function): void;
|
59 | overwriteProperty(ctx: object, name: string, getter: () => any): void;
|
60 | compareByInspect(a: object, b: object): -1 | 1;
|
61 | expectTypes(obj: object, types: string[]): void;
|
62 | flag(obj: object, key: string, value?: any): any;
|
63 | getActual(obj: object, args: AssertionArgs): any;
|
64 | getProperties(obj: object): string[];
|
65 | getEnumerableProperties(obj: object): string[];
|
66 | getOwnEnumerablePropertySymbols(obj: object): symbol[];
|
67 | getOwnEnumerableProperties(obj: object): Array<string | symbol>;
|
68 | getMessage(errorLike: Error | string): string;
|
69 | getMessage(obj: any, args: AssertionArgs): string;
|
70 | inspect(obj: any, showHidden?: boolean, depth?: number, colors?: boolean): string;
|
71 | isProxyEnabled(): boolean;
|
72 | objDisplay(obj: object): void;
|
73 | proxify(obj: object, nonChainableMethodName: string): object;
|
74 | test(obj: object, args: AssertionArgs): boolean;
|
75 | transferFlags(assertion: Assertion, obj: object, includeAll?: boolean): void;
|
76 | compatibleInstance(thrown: Error, errorLike: Error | ErrorConstructor): boolean;
|
77 | compatibleConstructor(thrown: Error, errorLike: Error | ErrorConstructor): boolean;
|
78 | compatibleMessage(thrown: Error, errMatcher: string | RegExp): boolean;
|
79 | getConstructorName(constructorFn: Function): string;
|
80 | getFuncName(constructorFn: Function): string | null;
|
81 |
|
82 | // Reexports from pathval:
|
83 | hasProperty(obj: object | undefined | null, name: ObjectProperty): boolean;
|
84 | getPathInfo(obj: object, path: string): PathInfo;
|
85 | getPathValue(obj: object, path: string): object | undefined;
|
86 | }
|
87 |
|
88 | type ChaiPlugin = (chai: ChaiStatic, utils: ChaiUtils) => void;
|
89 |
|
90 | interface ChaiStatic {
|
91 | expect: ExpectStatic;
|
92 | should(): Should;
|
93 | |
94 |
|
95 |
|
96 | use(fn: ChaiPlugin): ChaiStatic;
|
97 | util: ChaiUtils;
|
98 | assert: AssertStatic;
|
99 | config: Config;
|
100 | Assertion: AssertionStatic;
|
101 | AssertionError: typeof AssertionError;
|
102 | version: string;
|
103 | }
|
104 |
|
105 | export interface ExpectStatic {
|
106 | (val: any, message?: string): Assertion;
|
107 | fail(message?: string): never;
|
108 | fail(actual: any, expected: any, message?: string, operator?: Operator): never;
|
109 | }
|
110 |
|
111 | export interface AssertStatic extends Assert {
|
112 | }
|
113 |
|
114 |
|
115 | type AssertionArgs = [
|
116 |
|
117 |
|
118 |
|
119 |
|
120 | any,
|
121 | Message,
|
122 | Message,
|
123 | any,
|
124 | any?,
|
125 | boolean?
|
126 | ];
|
127 |
|
128 | export interface AssertionPrototype {
|
129 | assert(...args: AssertionArgs): void;
|
130 | _obj: any;
|
131 | }
|
132 |
|
133 | export interface AssertionStatic extends AssertionPrototype {
|
134 | prototype: AssertionPrototype;
|
135 |
|
136 | new(target: any, message?: string, ssfi?: Function, lockSsfi?: boolean): Assertion;
|
137 |
|
138 |
|
139 | includeStack: boolean;
|
140 | showDiff: boolean;
|
141 |
|
142 |
|
143 | addProperty(name: string, getter: (this: AssertionStatic) => any): void;
|
144 | addMethod(name: string, method: (this: AssertionStatic, ...args: any[]) => any): void;
|
145 | addChainableMethod(
|
146 | name: string,
|
147 | method: (this: AssertionStatic, ...args: any[]) => void,
|
148 | chainingBehavior?: () => void
|
149 | ): void;
|
150 | overwriteProperty(name: string, getter: (this: AssertionStatic) => any): void;
|
151 | overwriteMethod(name: string, method: (this: AssertionStatic, ...args: any[]) => any): void;
|
152 | overwriteChainableMethod(
|
153 | name: string,
|
154 | method: (this: AssertionStatic, ...args: any[]) => void,
|
155 | chainingBehavior?: () => void
|
156 | ): void;
|
157 | }
|
158 |
|
159 | export type Operator = string;
|
160 |
|
161 | export type OperatorComparable = boolean | null | number | string | undefined | Date;
|
162 |
|
163 | interface ShouldAssertion {
|
164 | equal(value1: any, value2: any, message?: string): void;
|
165 | Throw: ShouldThrow;
|
166 | throw: ShouldThrow;
|
167 | exist(value: any, message?: string): void;
|
168 | }
|
169 |
|
170 | interface Should extends ShouldAssertion {
|
171 | not: ShouldAssertion;
|
172 | fail(message?: string): never;
|
173 | fail(actual: any, expected: any, message?: string, operator?: Operator): never;
|
174 | }
|
175 |
|
176 | interface ShouldThrow {
|
177 | (actual: Function, expected?: string | RegExp, message?: string): void;
|
178 | (actual: Function, constructor: Error | Function, expected?: string | RegExp, message?: string): void;
|
179 | }
|
180 |
|
181 | interface Assertion extends LanguageChains, NumericComparison, TypeComparison {
|
182 | not: Assertion;
|
183 | deep: Deep;
|
184 | ordered: Ordered;
|
185 | nested: Nested;
|
186 | own: Own;
|
187 | any: KeyFilter;
|
188 | all: KeyFilter;
|
189 | a: Assertion;
|
190 | an: Assertion;
|
191 | include: Include;
|
192 | includes: Include;
|
193 | contain: Include;
|
194 | contains: Include;
|
195 | ok: Assertion;
|
196 | true: Assertion;
|
197 | false: Assertion;
|
198 | null: Assertion;
|
199 | undefined: Assertion;
|
200 | NaN: Assertion;
|
201 | exist: Assertion;
|
202 | empty: Assertion;
|
203 | arguments: Assertion;
|
204 | Arguments: Assertion;
|
205 | finite: Assertion;
|
206 | equal: Equal;
|
207 | equals: Equal;
|
208 | eq: Equal;
|
209 | eql: Equal;
|
210 | eqls: Equal;
|
211 | property: Property;
|
212 | ownProperty: Property;
|
213 | haveOwnProperty: Property;
|
214 | ownPropertyDescriptor: OwnPropertyDescriptor;
|
215 | haveOwnPropertyDescriptor: OwnPropertyDescriptor;
|
216 | length: Length;
|
217 | lengthOf: Length;
|
218 | match: Match;
|
219 | matches: Match;
|
220 | string(string: string, message?: string): Assertion;
|
221 | keys: Keys;
|
222 | key(string: string): Assertion;
|
223 | throw: Throw;
|
224 | throws: Throw;
|
225 | Throw: Throw;
|
226 | respondTo: RespondTo;
|
227 | respondsTo: RespondTo;
|
228 | itself: Assertion;
|
229 | satisfy: Satisfy;
|
230 | satisfies: Satisfy;
|
231 | closeTo: CloseTo;
|
232 | approximately: CloseTo;
|
233 | members: Members;
|
234 | increase: PropertyChange;
|
235 | increases: PropertyChange;
|
236 | decrease: PropertyChange;
|
237 | decreases: PropertyChange;
|
238 | change: PropertyChange;
|
239 | changes: PropertyChange;
|
240 | extensible: Assertion;
|
241 | sealed: Assertion;
|
242 | frozen: Assertion;
|
243 | oneOf: OneOf;
|
244 | }
|
245 |
|
246 | interface LanguageChains {
|
247 | to: Assertion;
|
248 | be: Assertion;
|
249 | been: Assertion;
|
250 | is: Assertion;
|
251 | that: Assertion;
|
252 | which: Assertion;
|
253 | and: Assertion;
|
254 | has: Assertion;
|
255 | have: Assertion;
|
256 | with: Assertion;
|
257 | at: Assertion;
|
258 | of: Assertion;
|
259 | same: Assertion;
|
260 | but: Assertion;
|
261 | does: Assertion;
|
262 | }
|
263 |
|
264 | interface NumericComparison {
|
265 | above: NumberComparer;
|
266 | gt: NumberComparer;
|
267 | greaterThan: NumberComparer;
|
268 | least: NumberComparer;
|
269 | gte: NumberComparer;
|
270 | greaterThanOrEqual: NumberComparer;
|
271 | below: NumberComparer;
|
272 | lt: NumberComparer;
|
273 | lessThan: NumberComparer;
|
274 | most: NumberComparer;
|
275 | lte: NumberComparer;
|
276 | lessThanOrEqual: NumberComparer;
|
277 | within(start: number, finish: number, message?: string): Assertion;
|
278 | within(start: Date, finish: Date, message?: string): Assertion;
|
279 | }
|
280 |
|
281 | interface NumberComparer {
|
282 | (value: number | Date, message?: string): Assertion;
|
283 | }
|
284 |
|
285 | interface TypeComparison {
|
286 | (type: string, message?: string): Assertion;
|
287 | instanceof: InstanceOf;
|
288 | instanceOf: InstanceOf;
|
289 | }
|
290 |
|
291 | interface InstanceOf {
|
292 | (constructor: any, message?: string): Assertion;
|
293 | }
|
294 |
|
295 | interface CloseTo {
|
296 | (expected: number, delta: number, message?: string): Assertion;
|
297 | }
|
298 |
|
299 | interface Nested {
|
300 | include: Include;
|
301 | includes: Include;
|
302 | contain: Include;
|
303 | contains: Include;
|
304 | property: Property;
|
305 | members: Members;
|
306 | }
|
307 |
|
308 | interface Own {
|
309 | include: Include;
|
310 | includes: Include;
|
311 | contain: Include;
|
312 | contains: Include;
|
313 | property: Property;
|
314 | }
|
315 |
|
316 | interface Deep extends KeyFilter {
|
317 | equal: Equal;
|
318 | equals: Equal;
|
319 | eq: Equal;
|
320 | include: Include;
|
321 | includes: Include;
|
322 | contain: Include;
|
323 | contains: Include;
|
324 | property: Property;
|
325 | ordered: Ordered;
|
326 | nested: Nested;
|
327 | own: Own;
|
328 | }
|
329 |
|
330 | interface Ordered {
|
331 | members: Members;
|
332 | }
|
333 |
|
334 | interface KeyFilter {
|
335 | keys: Keys;
|
336 | members: Members;
|
337 | }
|
338 |
|
339 | interface Equal {
|
340 | (value: any, message?: string): Assertion;
|
341 | }
|
342 |
|
343 | interface Property {
|
344 | (name: string | symbol, value: any, message?: string): Assertion;
|
345 | (name: string | symbol, message?: string): Assertion;
|
346 | }
|
347 |
|
348 | interface OwnPropertyDescriptor {
|
349 | (name: string | symbol, descriptor: PropertyDescriptor, message?: string): Assertion;
|
350 | (name: string | symbol, message?: string): Assertion;
|
351 | }
|
352 |
|
353 | interface Length extends LanguageChains, NumericComparison {
|
354 | (length: number, message?: string): Assertion;
|
355 | }
|
356 |
|
357 | interface Include {
|
358 | (value: any, message?: string): Assertion;
|
359 | keys: Keys;
|
360 | deep: Deep;
|
361 | ordered: Ordered;
|
362 | members: Members;
|
363 | any: KeyFilter;
|
364 | all: KeyFilter;
|
365 | oneOf: OneOf;
|
366 | }
|
367 |
|
368 | interface OneOf {
|
369 | (list: ReadonlyArray<unknown>, message?: string): Assertion;
|
370 | }
|
371 |
|
372 | interface Match {
|
373 | (regexp: RegExp, message?: string): Assertion;
|
374 | }
|
375 |
|
376 | interface Keys {
|
377 | (...keys: string[]): Assertion;
|
378 | (keys: ReadonlyArray<any> | Object): Assertion;
|
379 | }
|
380 |
|
381 | interface Throw {
|
382 | (expected?: string | RegExp, message?: string): Assertion;
|
383 | (constructor: Error | Function, expected?: string | RegExp, message?: string): Assertion;
|
384 | }
|
385 |
|
386 | interface RespondTo {
|
387 | (method: string, message?: string): Assertion;
|
388 | }
|
389 |
|
390 | interface Satisfy {
|
391 | (matcher: Function, message?: string): Assertion;
|
392 | }
|
393 |
|
394 | interface Members {
|
395 | (set: ReadonlyArray<any>, message?: string): Assertion;
|
396 | }
|
397 |
|
398 | interface PropertyChange {
|
399 | (object: Object, property?: string, message?: string): DeltaAssertion;
|
400 | }
|
401 |
|
402 | interface DeltaAssertion extends Assertion {
|
403 | by(delta: number, msg?: string): Assertion;
|
404 | }
|
405 |
|
406 | export interface Assert {
|
407 | |
408 |
|
409 |
|
410 |
|
411 | (expression: any, message?: string): void;
|
412 |
|
413 | |
414 |
|
415 |
|
416 |
|
417 |
|
418 |
|
419 | fail(message?: string): never;
|
420 |
|
421 | |
422 |
|
423 |
|
424 |
|
425 |
|
426 |
|
427 |
|
428 |
|
429 |
|
430 |
|
431 | fail<T>(actual: T, expected: T, message?: string, operator?: Operator): never;
|
432 |
|
433 | |
434 |
|
435 |
|
436 |
|
437 |
|
438 |
|
439 |
|
440 | isOk<T>(value: T, message?: string): void;
|
441 |
|
442 | |
443 |
|
444 |
|
445 |
|
446 |
|
447 |
|
448 |
|
449 | ok<T>(value: T, message?: string): void;
|
450 |
|
451 | |
452 |
|
453 |
|
454 |
|
455 |
|
456 |
|
457 |
|
458 | isNotOk<T>(value: T, message?: string): void;
|
459 |
|
460 | |
461 |
|
462 |
|
463 |
|
464 |
|
465 |
|
466 |
|
467 | notOk<T>(value: T, message?: string): void;
|
468 |
|
469 | |
470 |
|
471 |
|
472 |
|
473 |
|
474 |
|
475 |
|
476 |
|
477 | equal<T>(actual: T, expected: T, message?: string): void;
|
478 |
|
479 | |
480 |
|
481 |
|
482 |
|
483 |
|
484 |
|
485 |
|
486 |
|
487 | notEqual<T>(actual: T, expected: T, message?: string): void;
|
488 |
|
489 | |
490 |
|
491 |
|
492 |
|
493 |
|
494 |
|
495 |
|
496 |
|
497 | strictEqual<T>(actual: T, expected: T, message?: string): void;
|
498 |
|
499 | |
500 |
|
501 |
|
502 |
|
503 |
|
504 |
|
505 |
|
506 |
|
507 | notStrictEqual<T>(actual: T, expected: T, message?: string): void;
|
508 |
|
509 | |
510 |
|
511 |
|
512 |
|
513 |
|
514 |
|
515 |
|
516 |
|
517 | deepEqual<T>(actual: T, expected: T, message?: string): void;
|
518 |
|
519 | |
520 |
|
521 |
|
522 |
|
523 |
|
524 |
|
525 |
|
526 |
|
527 | notDeepEqual<T>(actual: T, expected: T, message?: string): void;
|
528 |
|
529 | |
530 |
|
531 |
|
532 |
|
533 |
|
534 |
|
535 |
|
536 |
|
537 | deepStrictEqual<T>(actual: T, expected: T, message?: string): void;
|
538 |
|
539 | |
540 |
|
541 |
|
542 |
|
543 |
|
544 |
|
545 |
|
546 | isAbove(valueToCheck: number, valueToBeAbove: number, message?: string): void;
|
547 |
|
548 | |
549 |
|
550 |
|
551 |
|
552 |
|
553 |
|
554 |
|
555 | isAtLeast(valueToCheck: number, valueToBeAtLeast: number, message?: string): void;
|
556 |
|
557 | |
558 |
|
559 |
|
560 |
|
561 |
|
562 |
|
563 |
|
564 | isBelow(valueToCheck: number, valueToBeBelow: number, message?: string): void;
|
565 |
|
566 | |
567 |
|
568 |
|
569 |
|
570 |
|
571 |
|
572 |
|
573 | isAtMost(valueToCheck: number, valueToBeAtMost: number, message?: string): void;
|
574 |
|
575 | |
576 |
|
577 |
|
578 |
|
579 |
|
580 |
|
581 |
|
582 | isTrue<T>(value: T, message?: string): void;
|
583 |
|
584 | |
585 |
|
586 |
|
587 |
|
588 |
|
589 |
|
590 |
|
591 | isFalse<T>(value: T, message?: string): void;
|
592 |
|
593 | |
594 |
|
595 |
|
596 |
|
597 |
|
598 |
|
599 |
|
600 | isNotTrue<T>(value: T, message?: string): void;
|
601 |
|
602 | |
603 |
|
604 |
|
605 |
|
606 |
|
607 |
|
608 |
|
609 | isNotFalse<T>(value: T, message?: string): void;
|
610 |
|
611 | |
612 |
|
613 |
|
614 |
|
615 |
|
616 |
|
617 |
|
618 | isNull<T>(value: T, message?: string): void;
|
619 |
|
620 | |
621 |
|
622 |
|
623 |
|
624 |
|
625 |
|
626 |
|
627 | isNotNull<T>(value: T, message?: string): void;
|
628 |
|
629 | |
630 |
|
631 |
|
632 |
|
633 |
|
634 |
|
635 |
|
636 | isNaN<T>(value: T, message?: string): void;
|
637 |
|
638 | |
639 |
|
640 |
|
641 |
|
642 |
|
643 |
|
644 |
|
645 | isNotNaN<T>(value: T, message?: string): void;
|
646 |
|
647 | |
648 |
|
649 |
|
650 |
|
651 |
|
652 |
|
653 |
|
654 | exists<T>(value: T, message?: string): void;
|
655 |
|
656 | |
657 |
|
658 |
|
659 |
|
660 |
|
661 |
|
662 |
|
663 | notExists<T>(value: T, message?: string): void;
|
664 |
|
665 | |
666 |
|
667 |
|
668 |
|
669 |
|
670 |
|
671 |
|
672 | isUndefined<T>(value: T, message?: string): void;
|
673 |
|
674 | |
675 |
|
676 |
|
677 |
|
678 |
|
679 |
|
680 |
|
681 | isDefined<T>(value: T, message?: string): void;
|
682 |
|
683 | |
684 |
|
685 |
|
686 |
|
687 |
|
688 |
|
689 |
|
690 | isFunction<T>(value: T, message?: string): void;
|
691 |
|
692 | |
693 |
|
694 |
|
695 |
|
696 |
|
697 |
|
698 |
|
699 | isNotFunction<T>(value: T, message?: string): void;
|
700 |
|
701 | |
702 |
|
703 |
|
704 |
|
705 |
|
706 |
|
707 |
|
708 |
|
709 |
|
710 | isObject<T>(value: T, message?: string): void;
|
711 |
|
712 | |
713 |
|
714 |
|
715 |
|
716 |
|
717 |
|
718 |
|
719 |
|
720 | isNotObject<T>(value: T, message?: string): void;
|
721 |
|
722 | |
723 |
|
724 |
|
725 |
|
726 |
|
727 |
|
728 |
|
729 | isArray<T>(value: T, message?: string): void;
|
730 |
|
731 | |
732 |
|
733 |
|
734 |
|
735 |
|
736 |
|
737 |
|
738 | isNotArray<T>(value: T, message?: string): void;
|
739 |
|
740 | |
741 |
|
742 |
|
743 |
|
744 |
|
745 |
|
746 |
|
747 | isString<T>(value: T, message?: string): void;
|
748 |
|
749 | |
750 |
|
751 |
|
752 |
|
753 |
|
754 |
|
755 |
|
756 | isNotString<T>(value: T, message?: string): void;
|
757 |
|
758 | |
759 |
|
760 |
|
761 |
|
762 |
|
763 |
|
764 |
|
765 | isNumber<T>(value: T, message?: string): void;
|
766 |
|
767 | |
768 |
|
769 |
|
770 |
|
771 |
|
772 |
|
773 |
|
774 | isNotNumber<T>(value: T, message?: string): void;
|
775 |
|
776 | |
777 |
|
778 |
|
779 |
|
780 |
|
781 |
|
782 |
|
783 |
|
784 | isFinite<T>(value: T, message?: string): void;
|
785 |
|
786 | |
787 |
|
788 |
|
789 |
|
790 |
|
791 |
|
792 |
|
793 | isBoolean<T>(value: T, message?: string): void;
|
794 |
|
795 | |
796 |
|
797 |
|
798 |
|
799 |
|
800 |
|
801 |
|
802 | isNotBoolean<T>(value: T, message?: string): void;
|
803 |
|
804 | |
805 |
|
806 |
|
807 |
|
808 |
|
809 |
|
810 |
|
811 |
|
812 | typeOf<T>(value: T, name: string, message?: string): void;
|
813 |
|
814 | |
815 |
|
816 |
|
817 |
|
818 |
|
819 |
|
820 |
|
821 |
|
822 | notTypeOf<T>(value: T, name: string, message?: string): void;
|
823 |
|
824 | |
825 |
|
826 |
|
827 |
|
828 |
|
829 |
|
830 |
|
831 |
|
832 | instanceOf<T>(value: T, constructor: Function, message?: string): void;
|
833 |
|
834 | /**
|
835 | * Asserts that value is not an instance of constructor.
|
836 | *
|
837 | * @type T Type of value.
|
838 | * @param value Actual value.
|
839 | * @param constructor Potential expected contructor of value.
|
840 | * @param message Message to display on error.
|
841 | */
|
842 | notInstanceOf<T>(value: T, type: Function, message?: string): void;
|
843 |
|
844 | /**
|
845 | * Asserts that haystack includes needle.
|
846 | *
|
847 | * @param haystack Container string.
|
848 | * @param needle Potential substring of haystack.
|
849 | * @param message Message to display on error.
|
850 | */
|
851 | include(haystack: string, needle: string, message?: string): void;
|
852 |
|
853 | /**
|
854 | * Asserts that haystack includes needle.
|
855 | *
|
856 | * @type T Type of values in haystack.
|
857 | * @param haystack Container array, set or map.
|
858 | * @param needle Potential value contained in haystack.
|
859 | * @param message Message to display on error.
|
860 | */
|
861 | include<T>(haystack: ReadonlyArray<T> | ReadonlySet<T> | ReadonlyMap<any, T>, needle: T, message?: string): void;
|
862 |
|
863 | /**
|
864 | * Asserts that haystack includes needle.
|
865 | *
|
866 | * @type T Type of values in haystack.
|
867 | * @param haystack WeakSet container.
|
868 | * @param needle Potential value contained in haystack.
|
869 | * @param message Message to display on error.
|
870 | */
|
871 | include<T extends object>(haystack: WeakSet<T>, needle: T, message?: string): void;
|
872 |
|
873 | /**
|
874 | * Asserts that haystack includes needle.
|
875 | *
|
876 | * @type T Type of haystack.
|
877 | * @param haystack Object.
|
878 | * @param needle Potential subset of the haystack's properties.
|
879 | * @param message Message to display on error.
|
880 | */
|
881 | include<T>(haystack: T, needle: Partial<T>, message?: string): void;
|
882 |
|
883 | /**
|
884 | * Asserts that haystack does not includes needle.
|
885 | *
|
886 | * @param haystack Container string.
|
887 | * @param needle Potential substring of haystack.
|
888 | * @param message Message to display on error.
|
889 | */
|
890 | notInclude(haystack: string, needle: string, message?: string): void;
|
891 |
|
892 | /**
|
893 | * Asserts that haystack does not includes needle.
|
894 | *
|
895 | * @type T Type of values in haystack.
|
896 | * @param haystack Container array, set or map.
|
897 | * @param needle Potential value contained in haystack.
|
898 | * @param message Message to display on error.
|
899 | */
|
900 | notInclude<T>(haystack: ReadonlyArray<T> | ReadonlySet<T> | ReadonlyMap<any, T>, needle: T, message?: string): void;
|
901 |
|
902 | /**
|
903 | * Asserts that haystack does not includes needle.
|
904 | *
|
905 | * @type T Type of values in haystack.
|
906 | * @param haystack WeakSet container.
|
907 | * @param needle Potential value contained in haystack.
|
908 | * @param message Message to display on error.
|
909 | */
|
910 | notInclude<T extends object>(haystack: WeakSet<T>, needle: T, message?: string): void;
|
911 |
|
912 | /**
|
913 | * Asserts that haystack does not includes needle.
|
914 | *
|
915 | * @type T Type of haystack.
|
916 | * @param haystack Object.
|
917 | * @param needle Potential subset of the haystack's properties.
|
918 | * @param message Message to display on error.
|
919 | */
|
920 | notInclude<T>(haystack: T, needle: Partial<T>, message?: string): void;
|
921 |
|
922 | /**
|
923 | * Asserts that haystack includes needle. Deep equality is used.
|
924 | *
|
925 | * @param haystack Container string.
|
926 | * @param needle Potential substring of haystack.
|
927 | * @param message Message to display on error.
|
928 | *
|
929 | * @deprecated Does not have any effect on string. Use {@link Assert#include} instead.
|
930 | */
|
931 | deepInclude(haystack: string, needle: string, message?: string): void;
|
932 |
|
933 | /**
|
934 | * Asserts that haystack includes needle. Deep equality is used.
|
935 | *
|
936 | * @type T Type of values in haystack.
|
937 | * @param haystack Container array, set or map.
|
938 | * @param needle Potential value contained in haystack.
|
939 | * @param message Message to display on error.
|
940 | */
|
941 | deepInclude<T>(haystack: ReadonlyArray<T> | ReadonlySet<T> | ReadonlyMap<any, T>, needle: T, message?: string): void;
|
942 |
|
943 | /**
|
944 | * Asserts that haystack does not includes needle.
|
945 | *
|
946 | * @type T Type of haystack.
|
947 | * @param haystack Object.
|
948 | * @param needle Potential subset of the haystack's properties.
|
949 | * @param message Message to display on error.
|
950 | */
|
951 | deepInclude<T>(haystack: T, needle: T extends WeakSet<any> ? never : Partial<T>, message?: string): void;
|
952 |
|
953 | /**
|
954 | * Asserts that haystack does not includes needle. Deep equality is used.
|
955 | *
|
956 | * @param haystack Container string.
|
957 | * @param needle Potential substring of haystack.
|
958 | * @param message Message to display on error.
|
959 | *
|
960 | * @deprecated Does not have any effect on string. Use {@link Assert#notInclude} instead.
|
961 | */
|
962 | notDeepInclude(haystack: string, needle: string, message?: string): void;
|
963 |
|
964 | /**
|
965 | * Asserts that haystack does not includes needle. Deep equality is used.
|
966 | *
|
967 | * @type T Type of values in haystack.
|
968 | * @param haystack Container array, set or map.
|
969 | * @param needle Potential value contained in haystack.
|
970 | * @param message Message to display on error.
|
971 | */
|
972 | notDeepInclude<T>(haystack: ReadonlyArray<T> | ReadonlySet<T> | ReadonlyMap<any, T>, needle: T, message?: string): void;
|
973 |
|
974 | /**
|
975 | * Asserts that haystack does not includes needle. Deep equality is used.
|
976 | *
|
977 | * @type T Type of haystack.
|
978 | * @param haystack Object.
|
979 | * @param needle Potential subset of the haystack's properties.
|
980 | * @param message Message to display on error.
|
981 | */
|
982 | notDeepInclude<T>(haystack: T, needle: T extends WeakSet<any> ? never : Partial<T>, message?: string): void;
|
983 |
|
984 | /**
|
985 | * Asserts that ‘haystack’ includes ‘needle’. Can be used to assert the inclusion of a subset of properties in an object.
|
986 | *
|
987 | * Enables the use of dot- and bracket-notation for referencing nested properties.
|
988 | * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.Asserts that ‘haystack’ includes ‘needle’.
|
989 | * Can be used to assert the inclusion of a subset of properties in an object.
|
990 | * Enables the use of dot- and bracket-notation for referencing nested properties.
|
991 | * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.
|
992 | *
|
993 | * @param haystack
|
994 | * @param needle
|
995 | * @param message Message to display on error.
|
996 | */
|
997 | nestedInclude(haystack: any, needle: any, message?: string): void;
|
998 |
|
999 | /**
|
1000 | * Asserts that ‘haystack’ does not include ‘needle’. Can be used to assert the absence of a subset of properties in an object.
|
1001 | *
|
1002 | * Enables the use of dot- and bracket-notation for referencing nested properties.
|
1003 | * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.Asserts that ‘haystack’ includes ‘needle’.
|
1004 | * Can be used to assert the inclusion of a subset of properties in an object.
|
1005 | * Enables the use of dot- and bracket-notation for referencing nested properties.
|
1006 | * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.
|
1007 | *
|
1008 | * @param haystack
|
1009 | * @param needle
|
1010 | * @param message Message to display on error.
|
1011 | */
|
1012 | notNestedInclude(haystack: any, needle: any, message?: string): void;
|
1013 |
|
1014 | /**
|
1015 | * 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
|
1016 | *
|
1017 | * Enables the use of dot- and bracket-notation for referencing nested properties.
|
1018 | * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.Asserts that ‘haystack’ includes ‘needle’.
|
1019 | * Can be used to assert the inclusion of a subset of properties in an object.
|
1020 | * Enables the use of dot- and bracket-notation for referencing nested properties.
|
1021 | * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.
|
1022 | *
|
1023 | * @param haystack
|
1024 | * @param needle
|
1025 | * @param message Message to display on error.
|
1026 | */
|
1027 | deepNestedInclude(haystack: any, needle: any, message?: string): void;
|
1028 |
|
1029 | /**
|
1030 | * 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.
|
1031 | *
|
1032 | * Enables the use of dot- and bracket-notation for referencing nested properties.
|
1033 | * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.Asserts that ‘haystack’ includes ‘needle’.
|
1034 | * Can be used to assert the inclusion of a subset of properties in an object.
|
1035 | * Enables the use of dot- and bracket-notation for referencing nested properties.
|
1036 | * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.
|
1037 | *
|
1038 | * @param haystack
|
1039 | * @param needle
|
1040 | * @param message Message to display on error.
|
1041 | */
|
1042 | notDeepNestedInclude(haystack: any, needle: any, message?: string): void;
|
1043 |
|
1044 | /**
|
1045 | * Asserts that ‘haystack’ includes ‘needle’. Can be used to assert the inclusion of a subset of properties in an object while ignoring inherited properties.
|
1046 | *
|
1047 | * @param haystack
|
1048 | * @param needle
|
1049 | * @param message Message to display on error.
|
1050 | */
|
1051 | ownInclude(haystack: any, needle: any, message?: string): void;
|
1052 |
|
1053 | /**
|
1054 | * Asserts that ‘haystack’ includes ‘needle’. Can be used to assert the absence of a subset of properties in an object while ignoring inherited properties.
|
1055 | *
|
1056 | * @param haystack
|
1057 | * @param needle
|
1058 | * @param message Message to display on error.
|
1059 | */
|
1060 | notOwnInclude(haystack: any, needle: any, message?: string): void;
|
1061 |
|
1062 | /**
|
1063 | * 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
|
1064 | *
|
1065 | * @param haystack
|
1066 | * @param needle
|
1067 | * @param message Message to display on error.
|
1068 | */
|
1069 | deepOwnInclude(haystack: any, needle: any, message?: string): void;
|
1070 |
|
1071 | /**
|
1072 | * 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.
|
1073 | *
|
1074 | * @param haystack
|
1075 | * @param needle
|
1076 | * @param message Message to display on error.
|
1077 | */
|
1078 | notDeepOwnInclude(haystack: any, needle: any, message?: string): void;
|
1079 |
|
1080 | /**
|
1081 | * Asserts that value matches the regular expression regexp.
|
1082 | *
|
1083 | * @param value Actual value.
|
1084 | * @param regexp Potential match of value.
|
1085 | * @param message Message to display on error.
|
1086 | */
|
1087 | match(value: string, regexp: RegExp, message?: string): void;
|
1088 |
|
1089 | /**
|
1090 | * Asserts that value does not match the regular expression regexp.
|
1091 | *
|
1092 | * @param value Actual value.
|
1093 | * @param regexp Potential match of value.
|
1094 | * @param message Message to display on error.
|
1095 | */
|
1096 | notMatch(expected: any, regexp: RegExp, message?: string): void;
|
1097 |
|
1098 | /**
|
1099 | * Asserts that object has a property named by property.
|
1100 | *
|
1101 | * @type T Type of object.
|
1102 | * @param object Container object.
|
1103 | * @param property Potential contained property of object.
|
1104 | * @param message Message to display on error.
|
1105 | */
|
1106 | property<T>(object: T, property: string , message?: string): void;
|
1107 |
|
1108 | /**
|
1109 | * Asserts that object has a property named by property.
|
1110 | *
|
1111 | * @type T Type of object.
|
1112 | * @param object Container object.
|
1113 | * @param property Potential contained property of object.
|
1114 | * @param message Message to display on error.
|
1115 | */
|
1116 | notProperty<T>(object: T, property: string , message?: string): void;
|
1117 |
|
1118 | /**
|
1119 | * Asserts that object has a property named by property, which can be a string
|
1120 | * using dot- and bracket-notation for deep reference.
|
1121 | *
|
1122 | * @type T Type of object.
|
1123 | * @param object Container object.
|
1124 | * @param property Potential contained property of object.
|
1125 | * @param message Message to display on error.
|
1126 | */
|
1127 | deepProperty<T>(object: T, property: string, message?: string): void;
|
1128 |
|
1129 | /**
|
1130 | * Asserts that object does not have a property named by property, which can be a
|
1131 | * string using dot- and bracket-notation for deep reference.
|
1132 | *
|
1133 | * @type T Type of object.
|
1134 | * @param object Container object.
|
1135 | * @param property Potential contained property of object.
|
1136 | * @param message Message to display on error.
|
1137 | */
|
1138 | notDeepProperty<T>(object: T, property: string, message?: string): void;
|
1139 |
|
1140 | /**
|
1141 | * Asserts that object has a property named by property with value given by value.
|
1142 | *
|
1143 | * @type T Type of object.
|
1144 | * @type V Type of value.
|
1145 | * @param object Container object.
|
1146 | * @param property Potential contained property of object.
|
1147 | * @param value Potential expected property value.
|
1148 | * @param message Message to display on error.
|
1149 | */
|
1150 | propertyVal<T, V>(object: T, property: string , value: V, message?: string): void;
|
1151 |
|
1152 | /**
|
1153 | * Asserts that object has a property named by property with value given by value.
|
1154 | *
|
1155 | * @type T Type of object.
|
1156 | * @type V Type of value.
|
1157 | * @param object Container object.
|
1158 | * @param property Potential contained property of object.
|
1159 | * @param value Potential expected property value.
|
1160 | * @param message Message to display on error.
|
1161 | */
|
1162 | notPropertyVal<T, V>(object: T, property: string , value: V, message?: string): void;
|
1163 |
|
1164 | /**
|
1165 | * Asserts that object has a property named by property, which can be a string
|
1166 | * using dot- and bracket-notation for deep reference.
|
1167 | *
|
1168 | * @type T Type of object.
|
1169 | * @type V Type of value.
|
1170 | * @param object Container object.
|
1171 | * @param property Potential contained property of object.
|
1172 | * @param value Potential expected property value.
|
1173 | * @param message Message to display on error.
|
1174 | */
|
1175 | deepPropertyVal<T, V>(object: T, property: string, value: V, message?: string): void;
|
1176 |
|
1177 | /**
|
1178 | * Asserts that object does not have a property named by property, which can be a
|
1179 | * string using dot- and bracket-notation for deep reference.
|
1180 | *
|
1181 | * @type T Type of object.
|
1182 | * @type V Type of value.
|
1183 | * @param object Container object.
|
1184 | * @param property Potential contained property of object.
|
1185 | * @param value Potential expected property value.
|
1186 | * @param message Message to display on error.
|
1187 | */
|
1188 | notDeepPropertyVal<T, V>(object: T, property: string, value: V, message?: string): void;
|
1189 |
|
1190 | /**
|
1191 | * Asserts that object has a length property with the expected value.
|
1192 | *
|
1193 | * @type T Type of object.
|
1194 | * @param object Container object.
|
1195 | * @param length Potential expected length of object.
|
1196 | * @param message Message to display on error.
|
1197 | */
|
1198 | lengthOf<T extends { readonly length?: number }>(object: T, length: number, message?: string): void;
|
1199 |
|
1200 | |
1201 |
|
1202 |
|
1203 |
|
1204 |
|
1205 |
|
1206 | throw(fn: () => void, message?: string): void;
|
1207 |
|
1208 | /**
|
1209 | * Asserts that function will throw an error with message matching regexp.
|
1210 | *
|
1211 | * @param fn Function that may throw.
|
1212 | * @param regExp Potential expected message match.
|
1213 | * @param message Message to display on error.
|
1214 | */
|
1215 | throw(fn: () => void, regExp: RegExp): void;
|
1216 |
|
1217 | /**
|
1218 | * Asserts that function will throw an error that is an instance of constructor.
|
1219 | *
|
1220 | * @param fn Function that may throw.
|
1221 | * @param constructor Potential expected error constructor.
|
1222 | * @param message Message to display on error.
|
1223 | */
|
1224 | throw(fn: () => void, constructor: ErrorConstructor, message?: string): void;
|
1225 |
|
1226 | /**
|
1227 | * Asserts that function will throw an error that is an instance of constructor
|
1228 | * and an error with message matching regexp.
|
1229 | *
|
1230 | * @param fn Function that may throw.
|
1231 | * @param constructor Potential expected error constructor.
|
1232 | * @param message Message to display on error.
|
1233 | */
|
1234 | throw(fn: () => void, constructor: ErrorConstructor, regExp: RegExp): void;
|
1235 |
|
1236 | /**
|
1237 | * Asserts that fn will throw an error.
|
1238 | *
|
1239 | * @param fn Function that may throw.
|
1240 | * @param message Message to display on error.
|
1241 | */
|
1242 | throws(fn: () => void, message?: string): void;
|
1243 |
|
1244 | /**
|
1245 | * Asserts that function will throw an error with message matching regexp.
|
1246 | *
|
1247 | * @param fn Function that may throw.
|
1248 | * @param errType Potential expected message match or error constructor.
|
1249 | * @param message Message to display on error.
|
1250 | */
|
1251 | throws(fn: () => void, errType: RegExp | ErrorConstructor, message?: string): void;
|
1252 |
|
1253 | /**
|
1254 | * Asserts that function will throw an error that is an instance of constructor
|
1255 | * and an error with message matching regexp.
|
1256 | *
|
1257 | * @param fn Function that may throw.
|
1258 | * @param constructor Potential expected error constructor.
|
1259 | * @param message Message to display on error.
|
1260 | */
|
1261 | throws(fn: () => void, constructor: ErrorConstructor, regExp: RegExp): void;
|
1262 |
|
1263 | /**
|
1264 | * Asserts that fn will throw an error.
|
1265 | *
|
1266 | * @param fn Function that may throw.
|
1267 | * @param message Message to display on error.
|
1268 | */
|
1269 | Throw(fn: () => void, message?: string): void;
|
1270 |
|
1271 | /**
|
1272 | * Asserts that function will throw an error with message matching regexp.
|
1273 | *
|
1274 | * @param fn Function that may throw.
|
1275 | * @param regExp Potential expected message match.
|
1276 | * @param message Message to display on error.
|
1277 | */
|
1278 | Throw(fn: () => void, regExp: RegExp): void;
|
1279 |
|
1280 | /**
|
1281 | * Asserts that function will throw an error that is an instance of constructor.
|
1282 | *
|
1283 | * @param fn Function that may throw.
|
1284 | * @param constructor Potential expected error constructor.
|
1285 | * @param message Message to display on error.
|
1286 | */
|
1287 | Throw(fn: () => void, constructor: ErrorConstructor, message?: string): void;
|
1288 |
|
1289 | /**
|
1290 | * Asserts that function will throw an error that is an instance of constructor
|
1291 | * and an error with message matching regexp.
|
1292 | *
|
1293 | * @param fn Function that may throw.
|
1294 | * @param constructor Potential expected error constructor.
|
1295 | * @param message Message to display on error.
|
1296 | */
|
1297 | Throw(fn: () => void, constructor: ErrorConstructor, regExp: RegExp): void;
|
1298 |
|
1299 | /**
|
1300 | * Asserts that fn will not throw an error.
|
1301 | *
|
1302 | * @param fn Function that may throw.
|
1303 | * @param message Message to display on error.
|
1304 | */
|
1305 | doesNotThrow(fn: () => void, message?: string): void;
|
1306 |
|
1307 | /**
|
1308 | * Asserts that function will throw an error with message matching regexp.
|
1309 | *
|
1310 | * @param fn Function that may throw.
|
1311 | * @param regExp Potential expected message match.
|
1312 | * @param message Message to display on error.
|
1313 | */
|
1314 | doesNotThrow(fn: () => void, regExp: RegExp): void;
|
1315 |
|
1316 | /**
|
1317 | * Asserts that function will throw an error that is an instance of constructor.
|
1318 | *
|
1319 | * @param fn Function that may throw.
|
1320 | * @param constructor Potential expected error constructor.
|
1321 | * @param message Message to display on error.
|
1322 | */
|
1323 | doesNotThrow(fn: () => void, constructor: ErrorConstructor, message?: string): void;
|
1324 |
|
1325 | /**
|
1326 | * Asserts that function will throw an error that is an instance of constructor
|
1327 | * and an error with message matching regexp.
|
1328 | *
|
1329 | * @param fn Function that may throw.
|
1330 | * @param constructor Potential expected error constructor.
|
1331 | * @param message Message to display on error.
|
1332 | */
|
1333 | doesNotThrow(fn: () => void, constructor: ErrorConstructor, regExp: RegExp): void;
|
1334 |
|
1335 | /**
|
1336 | * Compares two values using operator.
|
1337 | *
|
1338 | * @param val1 Left value during comparison.
|
1339 | * @param operator Comparison operator.
|
1340 | * @param val2 Right value during comparison.
|
1341 | * @param message Message to display on error.
|
1342 | */
|
1343 | operator(val1: OperatorComparable, operator: Operator, val2: OperatorComparable, message?: string): void;
|
1344 |
|
1345 | /**
|
1346 | * Asserts that the target is equal to expected, to within a +/- delta range.
|
1347 | *
|
1348 | * @param actual Actual value
|
1349 | * @param expected Potential expected value.
|
1350 | * @param delta Maximum differenced between values.
|
1351 | * @param message Message to display on error.
|
1352 | */
|
1353 | closeTo(actual: number, expected: number, delta: number, message?: string): void;
|
1354 |
|
1355 | /**
|
1356 | * Asserts that the target is equal to expected, to within a +/- delta range.
|
1357 | *
|
1358 | * @param actual Actual value
|
1359 | * @param expected Potential expected value.
|
1360 | * @param delta Maximum differenced between values.
|
1361 | * @param message Message to display on error.
|
1362 | */
|
1363 | approximately(act: number, exp: number, delta: number, message?: string): void;
|
1364 |
|
1365 | /**
|
1366 | * Asserts that set1 and set2 have the same members. Order is not take into account.
|
1367 | *
|
1368 | * @type T Type of set values.
|
1369 | * @param set1 Actual set of values.
|
1370 | * @param set2 Potential expected set of values.
|
1371 | * @param message Message to display on error.
|
1372 | */
|
1373 | sameMembers<T>(set1: T[], set2: T[], message?: string): void;
|
1374 |
|
1375 | /**
|
1376 | * Asserts that set1 and set2 have the same members using deep equality checking.
|
1377 | * Order is not take into account.
|
1378 | *
|
1379 | * @type T Type of set values.
|
1380 | * @param set1 Actual set of values.
|
1381 | * @param set2 Potential expected set of values.
|
1382 | * @param message Message to display on error.
|
1383 | */
|
1384 | sameDeepMembers<T>(set1: T[], set2: T[], message?: string): void;
|
1385 |
|
1386 | /**
|
1387 | * Asserts that set1 and set2 have the same members in the same order.
|
1388 | * Uses a strict equality check (===).
|
1389 | *
|
1390 | * @type T Type of set values.
|
1391 | * @param set1 Actual set of values.
|
1392 | * @param set2 Potential expected set of values.
|
1393 | * @param message Message to display on error.
|
1394 | */
|
1395 | sameOrderedMembers<T>(set1: T[], set2: T[], message?: string): void;
|
1396 |
|
1397 | /**
|
1398 | * Asserts that set1 and set2 don’t have the same members in the same order.
|
1399 | * Uses a strict equality check (===).
|
1400 | *
|
1401 | * @type T Type of set values.
|
1402 | * @param set1 Actual set of values.
|
1403 | * @param set2 Potential expected set of values.
|
1404 | * @param message Message to display on error.
|
1405 | */
|
1406 | notSameOrderedMembers<T>(set1: T[], set2: T[], message?: string): void;
|
1407 |
|
1408 | /**
|
1409 | * Asserts that set1 and set2 have the same members in the same order.
|
1410 | * Uses a deep equality check.
|
1411 | *
|
1412 | * @type T Type of set values.
|
1413 | * @param set1 Actual set of values.
|
1414 | * @param set2 Potential expected set of values.
|
1415 | * @param message Message to display on error.
|
1416 | */
|
1417 | sameDeepOrderedMembers<T>(set1: T[], set2: T[], message?: string): void;
|
1418 |
|
1419 | /**
|
1420 | * Asserts that set1 and set2 don’t have the same members in the same order.
|
1421 | * Uses a deep equality check.
|
1422 | *
|
1423 | * @type T Type of set values.
|
1424 | * @param set1 Actual set of values.
|
1425 | * @param set2 Potential expected set of values.
|
1426 | * @param message Message to display on error.
|
1427 | */
|
1428 | notSameDeepOrderedMembers<T>(set1: T[], set2: T[], message?: string): void;
|
1429 |
|
1430 | /**
|
1431 | * Asserts that subset is included in superset in the same order beginning with the first element in superset.
|
1432 | * Uses a strict equality check (===).
|
1433 | *
|
1434 | * @type T Type of set values.
|
1435 | * @param superset Actual set of values.
|
1436 | * @param subset Potential contained set of values.
|
1437 | * @param message Message to display on error.
|
1438 | */
|
1439 | includeOrderedMembers<T>(superset: T[], subset: T[], message?: string): void;
|
1440 |
|
1441 | /**
|
1442 | * Asserts that subset isn’t included in superset in the same order beginning with the first element in superset.
|
1443 | * Uses a strict equality check (===).
|
1444 | *
|
1445 | * @type T Type of set values.
|
1446 | * @param superset Actual set of values.
|
1447 | * @param subset Potential contained set of values.
|
1448 | * @param message Message to display on error.
|
1449 | */
|
1450 | notIncludeOrderedMembers<T>(superset: T[], subset: T[], message?: string): void;
|
1451 |
|
1452 | /**
|
1453 | * Asserts that subset is included in superset in the same order beginning with the first element in superset.
|
1454 | * Uses a deep equality check.
|
1455 | *
|
1456 | * @type T Type of set values.
|
1457 | * @param superset Actual set of values.
|
1458 | * @param subset Potential contained set of values.
|
1459 | * @param message Message to display on error.
|
1460 | */
|
1461 | includeDeepOrderedMembers<T>(superset: T[], subset: T[], message?: string): void;
|
1462 |
|
1463 | /**
|
1464 | * Asserts that subset isn’t included in superset in the same order beginning with the first element in superset.
|
1465 | * Uses a deep equality check.
|
1466 | *
|
1467 | * @type T Type of set values.
|
1468 | * @param superset Actual set of values.
|
1469 | * @param subset Potential contained set of values.
|
1470 | * @param message Message to display on error.
|
1471 | */
|
1472 | notIncludeDeepOrderedMembers<T>(superset: T[], subset: T[], message?: string): void;
|
1473 |
|
1474 | /**
|
1475 | * Asserts that subset is included in superset. Order is not take into account.
|
1476 | *
|
1477 | * @type T Type of set values.
|
1478 | * @param superset Actual set of values.
|
1479 | * @param subset Potential contained set of values.
|
1480 | * @param message Message to display on error.
|
1481 | */
|
1482 | includeMembers<T>(superset: T[], subset: T[], message?: string): void;
|
1483 |
|
1484 | /**
|
1485 | * Asserts that subset is included in superset using deep equality checking.
|
1486 | * Order is not take into account.
|
1487 | *
|
1488 | * @type T Type of set values.
|
1489 | * @param superset Actual set of values.
|
1490 | * @param subset Potential contained set of values.
|
1491 | * @param message Message to display on error.
|
1492 | */
|
1493 | includeDeepMembers<T>(superset: T[], subset: T[], message?: string): void;
|
1494 |
|
1495 | /**
|
1496 | * Asserts that non-object, non-array value inList appears in the flat array list.
|
1497 | *
|
1498 | * @type T Type of list values.
|
1499 | * @param inList Value expected to be in the list.
|
1500 | * @param list List of values.
|
1501 | * @param message Message to display on error.
|
1502 | */
|
1503 | oneOf<T>(inList: T, list: T[], message?: string): void;
|
1504 |
|
1505 | /**
|
1506 | * Asserts that a function changes the value of a property.
|
1507 | *
|
1508 | * @type T Type of object.
|
1509 | * @param modifier Function to run.
|
1510 | * @param object Container object.
|
1511 | * @param property Property of object expected to be modified.
|
1512 | * @param message Message to display on error.
|
1513 | */
|
1514 | changes<T>(modifier: Function, object: T, property: string , message?: string): void;
|
1515 |
|
1516 | /**
|
1517 | * Asserts that a function does not change the value of a property.
|
1518 | *
|
1519 | * @type T Type of object.
|
1520 | * @param modifier Function to run.
|
1521 | * @param object Container object.
|
1522 | * @param property Property of object expected not to be modified.
|
1523 | * @param message Message to display on error.
|
1524 | */
|
1525 | doesNotChange<T>(modifier: Function, object: T, property: string , message?: string): void;
|
1526 |
|
1527 | /**
|
1528 | * Asserts that a function increases an object property.
|
1529 | *
|
1530 | * @type T Type of object.
|
1531 | * @param modifier Function to run.
|
1532 | * @param object Container object.
|
1533 | * @param property Property of object expected to be increased.
|
1534 | * @param message Message to display on error.
|
1535 | */
|
1536 | increases<T>(modifier: Function, object: T, property: string , message?: string): void;
|
1537 |
|
1538 | /**
|
1539 | * Asserts that a function does not increase an object property.
|
1540 | *
|
1541 | * @type T Type of object.
|
1542 | * @param modifier Function to run.
|
1543 | * @param object Container object.
|
1544 | * @param property Property of object expected not to be increased.
|
1545 | * @param message Message to display on error.
|
1546 | */
|
1547 | doesNotIncrease<T>(modifier: Function, object: T, property: string , message?: string): void;
|
1548 |
|
1549 | /**
|
1550 | * Asserts that a function decreases an object property.
|
1551 | *
|
1552 | * @type T Type of object.
|
1553 | * @param modifier Function to run.
|
1554 | * @param object Container object.
|
1555 | * @param property Property of object expected to be decreased.
|
1556 | * @param message Message to display on error.
|
1557 | */
|
1558 | decreases<T>(modifier: Function, object: T, property: string , message?: string): void;
|
1559 |
|
1560 | /**
|
1561 | * Asserts that a function does not decrease an object property.
|
1562 | *
|
1563 | * @type T Type of object.
|
1564 | * @param modifier Function to run.
|
1565 | * @param object Container object.
|
1566 | * @param property Property of object expected not to be decreased.
|
1567 | * @param message Message to display on error.
|
1568 | */
|
1569 | doesNotDecrease<T>(modifier: Function, object: T, property: string , message?: string): void;
|
1570 |
|
1571 | /**
|
1572 | * Asserts if value is not a false value, and throws if it is a true value.
|
1573 | *
|
1574 | * @type T Type of object.
|
1575 | * @param object Actual value.
|
1576 | * @param message Message to display on error.
|
1577 | * @remarks This is added to allow for chai to be a drop-in replacement for
|
1578 | * Node’s assert class.
|
1579 | */
|
1580 | ifError<T>(object: T, message?: string): void;
|
1581 |
|
1582 | /**
|
1583 | * Asserts that object is extensible (can have new properties added to it).
|
1584 | *
|
1585 | * @type T Type of object
|
1586 | * @param object Actual value.
|
1587 | * @param message Message to display on error.
|
1588 | */
|
1589 | isExtensible<T>(object: T, message?: string): void;
|
1590 |
|
1591 | /**
|
1592 | * Asserts that object is extensible (can have new properties added to it).
|
1593 | *
|
1594 | * @type T Type of object
|
1595 | * @param object Actual value.
|
1596 | * @param message Message to display on error.
|
1597 | */
|
1598 | extensible<T>(object: T, message?: string): void;
|
1599 |
|
1600 | /**
|
1601 | * Asserts that object is not extensible.
|
1602 | *
|
1603 | * @type T Type of object
|
1604 | * @param object Actual value.
|
1605 | * @param message Message to display on error.
|
1606 | */
|
1607 | isNotExtensible<T>(object: T, message?: string): void;
|
1608 |
|
1609 | /**
|
1610 | * Asserts that object is not extensible.
|
1611 | *
|
1612 | * @type T Type of object
|
1613 | * @param object Actual value.
|
1614 | * @param message Message to display on error.
|
1615 | */
|
1616 | notExtensible<T>(object: T, message?: string): void;
|
1617 |
|
1618 | /**
|
1619 | * Asserts that object is sealed (can have new properties added to it
|
1620 | * and its existing properties cannot be removed).
|
1621 | *
|
1622 | * @type T Type of object
|
1623 | * @param object Actual value.
|
1624 | * @param message Message to display on error.
|
1625 | */
|
1626 | isSealed<T>(object: T, message?: string): void;
|
1627 |
|
1628 | /**
|
1629 | * Asserts that object is sealed (can have new properties added to it
|
1630 | * and its existing properties cannot be removed).
|
1631 | *
|
1632 | * @type T Type of object
|
1633 | * @param object Actual value.
|
1634 | * @param message Message to display on error.
|
1635 | */
|
1636 | sealed<T>(object: T, message?: string): void;
|
1637 |
|
1638 | /**
|
1639 | * Asserts that object is not sealed.
|
1640 | *
|
1641 | * @type T Type of object
|
1642 | * @param object Actual value.
|
1643 | * @param message Message to display on error.
|
1644 | */
|
1645 | isNotSealed<T>(object: T, message?: string): void;
|
1646 |
|
1647 | /**
|
1648 | * Asserts that object is not sealed.
|
1649 | *
|
1650 | * @type T Type of object
|
1651 | * @param object Actual value.
|
1652 | * @param message Message to display on error.
|
1653 | */
|
1654 | notSealed<T>(object: T, message?: string): void;
|
1655 |
|
1656 | /**
|
1657 | * Asserts that object is frozen (cannot have new properties added to it
|
1658 | * and its existing properties cannot be removed).
|
1659 | *
|
1660 | * @type T Type of object
|
1661 | * @param object Actual value.
|
1662 | * @param message Message to display on error.
|
1663 | */
|
1664 | isFrozen<T>(object: T, message?: string): void;
|
1665 |
|
1666 | /**
|
1667 | * Asserts that object is frozen (cannot have new properties added to it
|
1668 | * and its existing properties cannot be removed).
|
1669 | *
|
1670 | * @type T Type of object
|
1671 | * @param object Actual value.
|
1672 | * @param message Message to display on error.
|
1673 | */
|
1674 | frozen<T>(object: T, message?: string): void;
|
1675 |
|
1676 | /**
|
1677 | * Asserts that object is not frozen (cannot have new properties added to it
|
1678 | * and its existing properties cannot be removed).
|
1679 | *
|
1680 | * @type T Type of object
|
1681 | * @param object Actual value.
|
1682 | * @param message Message to display on error.
|
1683 | */
|
1684 | isNotFrozen<T>(object: T, message?: string): void;
|
1685 |
|
1686 | /**
|
1687 | * Asserts that object is not frozen (cannot have new properties added to it
|
1688 | * and its existing properties cannot be removed).
|
1689 | *
|
1690 | * @type T Type of object
|
1691 | * @param object Actual value.
|
1692 | * @param message Message to display on error.
|
1693 | */
|
1694 | notFrozen<T>(object: T, message?: string): void;
|
1695 |
|
1696 | /**
|
1697 | * Asserts that the target does not contain any values. For arrays and
|
1698 | * strings, it checks the length property. For Map and Set instances, it
|
1699 | * checks the size property. For non-function objects, it gets the count
|
1700 | * of own enumerable string keys.
|
1701 | *
|
1702 | * @type T Type of object
|
1703 | * @param object Actual value.
|
1704 | * @param message Message to display on error.
|
1705 | */
|
1706 | isEmpty<T>(object: T, message?: string): void;
|
1707 |
|
1708 | /**
|
1709 | * Asserts that the target contains values. For arrays and strings, it checks
|
1710 | * the length property. For Map and Set instances, it checks the size property.
|
1711 | * For non-function objects, it gets the count of own enumerable string keys.
|
1712 | *
|
1713 | * @type T Type of object.
|
1714 | * @param object Object to test.
|
1715 | * @param message Message to display on error.
|
1716 | */
|
1717 | isNotEmpty<T>(object: T, message?: string): void;
|
1718 |
|
1719 | /**
|
1720 | * Asserts that `object` has at least one of the `keys` provided.
|
1721 | * You can also provide a single object instead of a `keys` array and its keys
|
1722 | * will be used as the expected set of keys.
|
1723 | *
|
1724 | * @type T Type of object.
|
1725 | * @param object Object to test.
|
1726 | * @param keys Keys to check
|
1727 | * @param message Message to display on error.
|
1728 | */
|
1729 | hasAnyKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
|
1730 |
|
1731 | /**
|
1732 | * Asserts that `object` has all and only all of the `keys` provided.
|
1733 | * You can also provide a single object instead of a `keys` array and its keys
|
1734 | * will be used as the expected set of keys.
|
1735 | *
|
1736 | * @type T Type of object.
|
1737 | * @param object Object to test.
|
1738 | * @param keys Keys to check
|
1739 | * @param message Message to display on error.
|
1740 | */
|
1741 | hasAllKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
|
1742 |
|
1743 | /**
|
1744 | * Asserts that `object` has all of the `keys` provided but may have more keys not listed.
|
1745 | * You can also provide a single object instead of a `keys` array and its keys
|
1746 | * will be used as the expected set of keys.
|
1747 | *
|
1748 | * @type T Type of object.
|
1749 | * @param object Object to test.
|
1750 | * @param keys Keys to check
|
1751 | * @param message Message to display on error.
|
1752 | */
|
1753 | containsAllKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
|
1754 |
|
1755 | /**
|
1756 | * Asserts that `object` has none of the `keys` provided.
|
1757 | * You can also provide a single object instead of a `keys` array and its keys
|
1758 | * will be used as the expected set of keys.
|
1759 | *
|
1760 | * @type T Type of object.
|
1761 | * @param object Object to test.
|
1762 | * @param keys Keys to check
|
1763 | * @param message Message to display on error.
|
1764 | */
|
1765 | doesNotHaveAnyKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
|
1766 |
|
1767 | /**
|
1768 | * Asserts that `object` does not have at least one of the `keys` provided.
|
1769 | * You can also provide a single object instead of a `keys` array and its keys
|
1770 | * will be used as the expected set of keys.
|
1771 | *
|
1772 | * @type T Type of object.
|
1773 | * @param object Object to test.
|
1774 | * @param keys Keys to check
|
1775 | * @param message Message to display on error.
|
1776 | */
|
1777 | doesNotHaveAllKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
|
1778 |
|
1779 | /**
|
1780 | * Asserts that `object` has at least one of the `keys` provided.
|
1781 | * Since Sets and Maps can have objects as keys you can use this assertion to perform
|
1782 | * a deep comparison.
|
1783 | * You can also provide a single object instead of a `keys` array and its keys
|
1784 | * will be used as the expected set of keys.
|
1785 | *
|
1786 | * @type T Type of object.
|
1787 | * @param object Object to test.
|
1788 | * @param keys Keys to check
|
1789 | * @param message Message to display on error.
|
1790 | */
|
1791 | hasAnyDeepKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
|
1792 |
|
1793 | /**
|
1794 | * Asserts that `object` has all and only all of the `keys` provided.
|
1795 | * Since Sets and Maps can have objects as keys you can use this assertion to perform
|
1796 | * a deep comparison.
|
1797 | * You can also provide a single object instead of a `keys` array and its keys
|
1798 | * will be used as the expected set of keys.
|
1799 | *
|
1800 | * @type T Type of object.
|
1801 | * @param object Object to test.
|
1802 | * @param keys Keys to check
|
1803 | * @param message Message to display on error.
|
1804 | */
|
1805 | hasAllDeepKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
|
1806 |
|
1807 | /**
|
1808 | * Asserts that `object` contains all of the `keys` provided.
|
1809 | * Since Sets and Maps can have objects as keys you can use this assertion to perform
|
1810 | * a deep comparison.
|
1811 | * You can also provide a single object instead of a `keys` array and its keys
|
1812 | * will be used as the expected set of keys.
|
1813 | *
|
1814 | * @type T Type of object.
|
1815 | * @param object Object to test.
|
1816 | * @param keys Keys to check
|
1817 | * @param message Message to display on error.
|
1818 | */
|
1819 | containsAllDeepKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
|
1820 |
|
1821 | /**
|
1822 | * Asserts that `object` contains all of the `keys` provided.
|
1823 | * Since Sets and Maps can have objects as keys you can use this assertion to perform
|
1824 | * a deep comparison.
|
1825 | * You can also provide a single object instead of a `keys` array and its keys
|
1826 | * will be used as the expected set of keys.
|
1827 | *
|
1828 | * @type T Type of object.
|
1829 | * @param object Object to test.
|
1830 | * @param keys Keys to check
|
1831 | * @param message Message to display on error.
|
1832 | */
|
1833 | doesNotHaveAnyDeepKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
|
1834 |
|
1835 | /**
|
1836 | * Asserts that `object` contains all of the `keys` provided.
|
1837 | * Since Sets and Maps can have objects as keys you can use this assertion to perform
|
1838 | * a deep comparison.
|
1839 | * You can also provide a single object instead of a `keys` array and its keys
|
1840 | * will be used as the expected set of keys.
|
1841 | *
|
1842 | * @type T Type of object.
|
1843 | * @param object Object to test.
|
1844 | * @param keys Keys to check
|
1845 | * @param message Message to display on error.
|
1846 | */
|
1847 | doesNotHaveAllDeepKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
|
1848 |
|
1849 | /**
|
1850 | * Asserts that object has a direct or inherited property named by property,
|
1851 | * which can be a string using dot- and bracket-notation for nested reference.
|
1852 | *
|
1853 | * @type T Type of object.
|
1854 | * @param object Object to test.
|
1855 | * @param property Property to test.
|
1856 | * @param message Message to display on error.
|
1857 | */
|
1858 | nestedProperty<T>(object: T, property: string, message?: string): void;
|
1859 |
|
1860 | /**
|
1861 | * Asserts that object does not have a property named by property,
|
1862 | * which can be a string using dot- and bracket-notation for nested reference.
|
1863 | * The property cannot exist on the object nor anywhere in its prototype chain.
|
1864 | *
|
1865 | * @type T Type of object.
|
1866 | * @param object Object to test.
|
1867 | * @param property Property to test.
|
1868 | * @param message Message to display on error.
|
1869 | */
|
1870 | notNestedProperty<T>(object: T, property: string, message?: string): void;
|
1871 |
|
1872 | /**
|
1873 | * Asserts that object has a property named by property with value given by value.
|
1874 | * property can use dot- and bracket-notation for nested reference. Uses a strict equality check (===).
|
1875 | *
|
1876 | * @type T Type of object.
|
1877 | * @param object Object to test.
|
1878 | * @param property Property to test.
|
1879 | * @param value Value to test.
|
1880 | * @param message Message to display on error.
|
1881 | */
|
1882 | nestedPropertyVal<T>(object: T, property: string, value: any, message?: string): void;
|
1883 |
|
1884 | /**
|
1885 | * Asserts that object does not have a property named by property with value given by value.
|
1886 | * property can use dot- and bracket-notation for nested reference. Uses a strict equality check (===).
|
1887 | *
|
1888 | * @type T Type of object.
|
1889 | * @param object Object to test.
|
1890 | * @param property Property to test.
|
1891 | * @param value Value to test.
|
1892 | * @param message Message to display on error.
|
1893 | */
|
1894 | notNestedPropertyVal<T>(object: T, property: string, value: any, message?: string): void;
|
1895 |
|
1896 | /**
|
1897 | * Asserts that object has a property named by property with a value given by value.
|
1898 | * property can use dot- and bracket-notation for nested reference. Uses a deep equality check.
|
1899 | *
|
1900 | * @type T Type of object.
|
1901 | * @param object Object to test.
|
1902 | * @param property Property to test.
|
1903 | * @param value Value to test.
|
1904 | * @param message Message to display on error.
|
1905 | */
|
1906 | deepNestedPropertyVal<T>(object: T, property: string, value: any, message?: string): void;
|
1907 |
|
1908 | /**
|
1909 | * Asserts that object does not have a property named by property with value given by value.
|
1910 | * property can use dot- and bracket-notation for nested reference. Uses a deep equality check.
|
1911 | *
|
1912 | * @type T Type of object.
|
1913 | * @param object Object to test.
|
1914 | * @param property Property to test.
|
1915 | * @param value Value to test.
|
1916 | * @param message Message to display on error.
|
1917 | */
|
1918 | notDeepNestedPropertyVal<T>(object: T, property: string, value: any, message?: string): void;
|
1919 | }
|
1920 |
|
1921 | export interface Config {
|
1922 | /**
|
1923 | * Default: false
|
1924 | */
|
1925 | includeStack: boolean;
|
1926 |
|
1927 | /**
|
1928 | * Default: true
|
1929 | */
|
1930 | showDiff: boolean;
|
1931 |
|
1932 | /**
|
1933 | * Default: 40
|
1934 | */
|
1935 | truncateThreshold: number;
|
1936 |
|
1937 | /**
|
1938 | * Default: true
|
1939 | */
|
1940 | useProxy: boolean;
|
1941 |
|
1942 | /**
|
1943 | * Default: ['then', 'catch', 'inspect', 'toJSON']
|
1944 | */
|
1945 | proxyExcludedKeys: string[];
|
1946 | }
|
1947 |
|
1948 | export class AssertionError {
|
1949 | constructor(message: string, _props?: any, ssf?: Function);
|
1950 | name: string;
|
1951 | message: string;
|
1952 | showDiff: boolean;
|
1953 | stack: string;
|
1954 | }
|
1955 | }
|
1956 |
|
1957 | declare const chai: Chai.ChaiStatic;
|
1958 |
|
1959 | declare module "chai" {
|
1960 | export = chai;
|
1961 | }
|
1962 |
|
1963 | interface Object {
|
1964 | should: Chai.Assertion;
|
1965 | }
|
1966 |
|
\ | No newline at end of file |