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