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 | be: Assertion;
|
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 | oneOf: OneOf;
|
328 | own: Own;
|
329 | }
|
330 |
|
331 | interface Ordered {
|
332 | members: Members;
|
333 | }
|
334 |
|
335 | interface KeyFilter {
|
336 | keys: Keys;
|
337 | members: Members;
|
338 | }
|
339 |
|
340 | interface Equal {
|
341 | (value: any, message?: string): Assertion;
|
342 | }
|
343 |
|
344 | interface Property {
|
345 | (name: string | symbol, value: any, message?: string): Assertion;
|
346 | (name: string | symbol, message?: string): Assertion;
|
347 | }
|
348 |
|
349 | interface OwnPropertyDescriptor {
|
350 | (name: string | symbol, descriptor: PropertyDescriptor, message?: string): Assertion;
|
351 | (name: string | symbol, message?: string): Assertion;
|
352 | }
|
353 |
|
354 | interface Length extends LanguageChains, NumericComparison {
|
355 | (length: number, message?: string): Assertion;
|
356 | }
|
357 |
|
358 | interface Include {
|
359 | (value: any, message?: string): Assertion;
|
360 | keys: Keys;
|
361 | deep: Deep;
|
362 | ordered: Ordered;
|
363 | members: Members;
|
364 | any: KeyFilter;
|
365 | all: KeyFilter;
|
366 | oneOf: OneOf;
|
367 | }
|
368 |
|
369 | interface OneOf {
|
370 | (list: ReadonlyArray<unknown>, message?: string): Assertion;
|
371 | }
|
372 |
|
373 | interface Match {
|
374 | (regexp: RegExp, message?: string): Assertion;
|
375 | }
|
376 |
|
377 | interface Keys {
|
378 | (...keys: string[]): Assertion;
|
379 | (keys: ReadonlyArray<any> | Object): Assertion;
|
380 | }
|
381 |
|
382 | interface Throw {
|
383 | (expected?: string | RegExp, message?: string): Assertion;
|
384 | (constructor: Error | Function, expected?: string | RegExp, message?: string): Assertion;
|
385 | }
|
386 |
|
387 | interface RespondTo {
|
388 | (method: string, message?: string): Assertion;
|
389 | }
|
390 |
|
391 | interface Satisfy {
|
392 | (matcher: Function, message?: string): Assertion;
|
393 | }
|
394 |
|
395 | interface Members {
|
396 | (set: ReadonlyArray<any>, message?: string): Assertion;
|
397 | }
|
398 |
|
399 | interface PropertyChange {
|
400 | (object: Object, property?: string, message?: string): DeltaAssertion;
|
401 | }
|
402 |
|
403 | interface DeltaAssertion extends Assertion {
|
404 | by(delta: number, msg?: string): Assertion;
|
405 | }
|
406 |
|
407 | export interface Assert {
|
408 | |
409 |
|
410 |
|
411 |
|
412 | (expression: any, message?: string): asserts expression;
|
413 |
|
414 | |
415 |
|
416 |
|
417 |
|
418 |
|
419 |
|
420 | fail(message?: string): never;
|
421 |
|
422 | |
423 |
|
424 |
|
425 |
|
426 |
|
427 |
|
428 |
|
429 |
|
430 |
|
431 |
|
432 | fail<T>(actual: T, expected: T, message?: string, operator?: Operator): never;
|
433 |
|
434 | |
435 |
|
436 |
|
437 |
|
438 |
|
439 |
|
440 |
|
441 | isOk<T>(value: T, message?: string): void;
|
442 |
|
443 | |
444 |
|
445 |
|
446 |
|
447 |
|
448 |
|
449 |
|
450 | ok<T>(value: T, message?: string): void;
|
451 |
|
452 | |
453 |
|
454 |
|
455 |
|
456 |
|
457 |
|
458 |
|
459 | isNotOk<T>(value: T, message?: string): void;
|
460 |
|
461 | |
462 |
|
463 |
|
464 |
|
465 |
|
466 |
|
467 |
|
468 | notOk<T>(value: T, message?: string): void;
|
469 |
|
470 | |
471 |
|
472 |
|
473 |
|
474 |
|
475 |
|
476 |
|
477 |
|
478 | equal<T>(actual: T, expected: T, message?: string): void;
|
479 |
|
480 | |
481 |
|
482 |
|
483 |
|
484 |
|
485 |
|
486 |
|
487 |
|
488 | notEqual<T>(actual: T, expected: T, message?: string): void;
|
489 |
|
490 | |
491 |
|
492 |
|
493 |
|
494 |
|
495 |
|
496 |
|
497 |
|
498 | strictEqual<T>(actual: T, expected: T, message?: string): void;
|
499 |
|
500 | |
501 |
|
502 |
|
503 |
|
504 |
|
505 |
|
506 |
|
507 |
|
508 | notStrictEqual<T>(actual: T, expected: T, message?: string): void;
|
509 |
|
510 | |
511 |
|
512 |
|
513 |
|
514 |
|
515 |
|
516 |
|
517 |
|
518 | deepEqual<T>(actual: T, expected: T, message?: string): void;
|
519 |
|
520 | |
521 |
|
522 |
|
523 |
|
524 |
|
525 |
|
526 |
|
527 |
|
528 | notDeepEqual<T>(actual: T, expected: T, message?: string): void;
|
529 |
|
530 | |
531 |
|
532 |
|
533 |
|
534 |
|
535 |
|
536 |
|
537 |
|
538 | deepStrictEqual<T>(actual: T, expected: T, message?: string): void;
|
539 |
|
540 | |
541 |
|
542 |
|
543 |
|
544 |
|
545 |
|
546 |
|
547 | isAbove(valueToCheck: number, valueToBeAbove: number, message?: string): void;
|
548 |
|
549 | |
550 |
|
551 |
|
552 |
|
553 |
|
554 |
|
555 |
|
556 | isAtLeast(valueToCheck: number, valueToBeAtLeast: number, message?: string): void;
|
557 |
|
558 | |
559 |
|
560 |
|
561 |
|
562 |
|
563 |
|
564 |
|
565 | isBelow(valueToCheck: number, valueToBeBelow: number, message?: string): void;
|
566 |
|
567 | |
568 |
|
569 |
|
570 |
|
571 |
|
572 |
|
573 |
|
574 | isAtMost(valueToCheck: number, valueToBeAtMost: number, message?: string): void;
|
575 |
|
576 | |
577 |
|
578 |
|
579 |
|
580 |
|
581 |
|
582 |
|
583 | isTrue<T>(value: T, message?: string): void;
|
584 |
|
585 | |
586 |
|
587 |
|
588 |
|
589 |
|
590 |
|
591 |
|
592 | isFalse<T>(value: T, message?: string): void;
|
593 |
|
594 | |
595 |
|
596 |
|
597 |
|
598 |
|
599 |
|
600 |
|
601 | isNotTrue<T>(value: T, message?: string): void;
|
602 |
|
603 | |
604 |
|
605 |
|
606 |
|
607 |
|
608 |
|
609 |
|
610 | isNotFalse<T>(value: T, message?: string): void;
|
611 |
|
612 | |
613 |
|
614 |
|
615 |
|
616 |
|
617 |
|
618 |
|
619 | isNull<T>(value: T, message?: string): void;
|
620 |
|
621 | |
622 |
|
623 |
|
624 |
|
625 |
|
626 |
|
627 |
|
628 | isNotNull<T>(value: T, message?: string): void;
|
629 |
|
630 | |
631 |
|
632 |
|
633 |
|
634 |
|
635 |
|
636 |
|
637 | isNaN<T>(value: T, message?: string): void;
|
638 |
|
639 | |
640 |
|
641 |
|
642 |
|
643 |
|
644 |
|
645 |
|
646 | isNotNaN<T>(value: T, message?: string): void;
|
647 |
|
648 | |
649 |
|
650 |
|
651 |
|
652 |
|
653 |
|
654 |
|
655 | exists<T>(value: T, message?: string): void;
|
656 |
|
657 | |
658 |
|
659 |
|
660 |
|
661 |
|
662 |
|
663 |
|
664 | notExists<T>(value: T, message?: string): void;
|
665 |
|
666 | |
667 |
|
668 |
|
669 |
|
670 |
|
671 |
|
672 |
|
673 | isUndefined<T>(value: T, message?: string): void;
|
674 |
|
675 | |
676 |
|
677 |
|
678 |
|
679 |
|
680 |
|
681 |
|
682 | isDefined<T>(value: T, message?: string): void;
|
683 |
|
684 | |
685 |
|
686 |
|
687 |
|
688 |
|
689 |
|
690 |
|
691 | isFunction<T>(value: T, message?: string): void;
|
692 |
|
693 | |
694 |
|
695 |
|
696 |
|
697 |
|
698 |
|
699 |
|
700 | isNotFunction<T>(value: T, message?: string): void;
|
701 |
|
702 | |
703 |
|
704 |
|
705 |
|
706 |
|
707 |
|
708 |
|
709 |
|
710 |
|
711 | isObject<T>(value: T, message?: string): void;
|
712 |
|
713 | |
714 |
|
715 |
|
716 |
|
717 |
|
718 |
|
719 |
|
720 |
|
721 | isNotObject<T>(value: T, message?: string): void;
|
722 |
|
723 | |
724 |
|
725 |
|
726 |
|
727 |
|
728 |
|
729 |
|
730 | isArray<T>(value: T, message?: string): void;
|
731 |
|
732 | |
733 |
|
734 |
|
735 |
|
736 |
|
737 |
|
738 |
|
739 | isNotArray<T>(value: T, message?: string): void;
|
740 |
|
741 | |
742 |
|
743 |
|
744 |
|
745 |
|
746 |
|
747 |
|
748 | isString<T>(value: T, message?: string): void;
|
749 |
|
750 | |
751 |
|
752 |
|
753 |
|
754 |
|
755 |
|
756 |
|
757 | isNotString<T>(value: T, message?: string): void;
|
758 |
|
759 | |
760 |
|
761 |
|
762 |
|
763 |
|
764 |
|
765 |
|
766 | isNumber<T>(value: T, message?: string): void;
|
767 |
|
768 | |
769 |
|
770 |
|
771 |
|
772 |
|
773 |
|
774 |
|
775 | isNotNumber<T>(value: T, message?: string): void;
|
776 |
|
777 | |
778 |
|
779 |
|
780 |
|
781 |
|
782 |
|
783 |
|
784 |
|
785 | isFinite<T>(value: T, message?: string): void;
|
786 |
|
787 | |
788 |
|
789 |
|
790 |
|
791 |
|
792 |
|
793 |
|
794 | isBoolean<T>(value: T, message?: string): void;
|
795 |
|
796 | |
797 |
|
798 |
|
799 |
|
800 |
|
801 |
|
802 |
|
803 | isNotBoolean<T>(value: T, message?: string): void;
|
804 |
|
805 | |
806 |
|
807 |
|
808 |
|
809 |
|
810 |
|
811 |
|
812 |
|
813 | typeOf<T>(value: T, name: string, message?: string): void;
|
814 |
|
815 | |
816 |
|
817 |
|
818 |
|
819 |
|
820 |
|
821 |
|
822 |
|
823 | notTypeOf<T>(value: T, name: string, message?: string): void;
|
824 |
|
825 | |
826 |
|
827 |
|
828 |
|
829 |
|
830 |
|
831 |
|
832 |
|
833 | instanceOf<T>(value: T, constructor: Function, message?: string): void;
|
834 |
|
835 | /**
|
836 | * Asserts that value is not an instance of constructor.
|
837 | *
|
838 | * @type T Type of value.
|
839 | * @param value Actual value.
|
840 | * @param constructor Potential expected contructor of value.
|
841 | * @param message Message to display on error.
|
842 | */
|
843 | notInstanceOf<T>(value: T, type: Function, message?: string): void;
|
844 |
|
845 | /**
|
846 | * Asserts that haystack includes needle.
|
847 | *
|
848 | * @param haystack Container string.
|
849 | * @param needle Potential substring of haystack.
|
850 | * @param message Message to display on error.
|
851 | */
|
852 | include(haystack: string, needle: string, message?: string): void;
|
853 |
|
854 | /**
|
855 | * Asserts that haystack includes needle.
|
856 | *
|
857 | * @type T Type of values in haystack.
|
858 | * @param haystack Container array, set or map.
|
859 | * @param needle Potential value contained in haystack.
|
860 | * @param message Message to display on error.
|
861 | */
|
862 | include<T>(haystack: ReadonlyArray<T> | ReadonlySet<T> | ReadonlyMap<any, T>, needle: T, message?: string): void;
|
863 |
|
864 | /**
|
865 | * Asserts that haystack includes needle.
|
866 | *
|
867 | * @type T Type of values in haystack.
|
868 | * @param haystack WeakSet container.
|
869 | * @param needle Potential value contained in haystack.
|
870 | * @param message Message to display on error.
|
871 | */
|
872 | include<T extends object>(haystack: WeakSet<T>, needle: T, message?: string): void;
|
873 |
|
874 | /**
|
875 | * Asserts that haystack includes needle.
|
876 | *
|
877 | * @type T Type of haystack.
|
878 | * @param haystack Object.
|
879 | * @param needle Potential subset of the haystack's properties.
|
880 | * @param message Message to display on error.
|
881 | */
|
882 | include<T>(haystack: T, needle: Partial<T>, message?: string): void;
|
883 |
|
884 | /**
|
885 | * Asserts that haystack does not includes needle.
|
886 | *
|
887 | * @param haystack Container string.
|
888 | * @param needle Potential substring of haystack.
|
889 | * @param message Message to display on error.
|
890 | */
|
891 | notInclude(haystack: string, needle: string, message?: string): void;
|
892 |
|
893 | /**
|
894 | * Asserts that haystack does not includes needle.
|
895 | *
|
896 | * @type T Type of values in haystack.
|
897 | * @param haystack Container array, set or map.
|
898 | * @param needle Potential value contained in haystack.
|
899 | * @param message Message to display on error.
|
900 | */
|
901 | notInclude<T>(haystack: ReadonlyArray<T> | ReadonlySet<T> | ReadonlyMap<any, T>, needle: T, message?: string): void;
|
902 |
|
903 | /**
|
904 | * Asserts that haystack does not includes needle.
|
905 | *
|
906 | * @type T Type of values in haystack.
|
907 | * @param haystack WeakSet container.
|
908 | * @param needle Potential value contained in haystack.
|
909 | * @param message Message to display on error.
|
910 | */
|
911 | notInclude<T extends object>(haystack: WeakSet<T>, needle: T, message?: string): void;
|
912 |
|
913 | /**
|
914 | * Asserts that haystack does not includes needle.
|
915 | *
|
916 | * @type T Type of haystack.
|
917 | * @param haystack Object.
|
918 | * @param needle Potential subset of the haystack's properties.
|
919 | * @param message Message to display on error.
|
920 | */
|
921 | notInclude<T>(haystack: T, needle: Partial<T>, message?: string): void;
|
922 |
|
923 | /**
|
924 | * Asserts that haystack includes needle. Deep equality is used.
|
925 | *
|
926 | * @param haystack Container string.
|
927 | * @param needle Potential substring of haystack.
|
928 | * @param message Message to display on error.
|
929 | *
|
930 | * @deprecated Does not have any effect on string. Use {@link Assert#include} instead.
|
931 | */
|
932 | deepInclude(haystack: string, needle: string, message?: string): void;
|
933 |
|
934 | /**
|
935 | * Asserts that haystack includes needle. Deep equality is used.
|
936 | *
|
937 | * @type T Type of values in haystack.
|
938 | * @param haystack Container array, set or map.
|
939 | * @param needle Potential value contained in haystack.
|
940 | * @param message Message to display on error.
|
941 | */
|
942 | deepInclude<T>(haystack: ReadonlyArray<T> | ReadonlySet<T> | ReadonlyMap<any, T>, needle: T, message?: string): void;
|
943 |
|
944 | /**
|
945 | * Asserts that haystack does not includes needle.
|
946 | *
|
947 | * @type T Type of haystack.
|
948 | * @param haystack Object.
|
949 | * @param needle Potential subset of the haystack's properties.
|
950 | * @param message Message to display on error.
|
951 | */
|
952 | deepInclude<T>(haystack: T, needle: T extends WeakSet<any> ? never : Partial<T>, message?: string): void;
|
953 |
|
954 | /**
|
955 | * Asserts that haystack does not includes needle. Deep equality is used.
|
956 | *
|
957 | * @param haystack Container string.
|
958 | * @param needle Potential substring of haystack.
|
959 | * @param message Message to display on error.
|
960 | *
|
961 | * @deprecated Does not have any effect on string. Use {@link Assert#notInclude} instead.
|
962 | */
|
963 | notDeepInclude(haystack: string, needle: string, message?: string): void;
|
964 |
|
965 | /**
|
966 | * Asserts that haystack does not includes needle. Deep equality is used.
|
967 | *
|
968 | * @type T Type of values in haystack.
|
969 | * @param haystack Container array, set or map.
|
970 | * @param needle Potential value contained in haystack.
|
971 | * @param message Message to display on error.
|
972 | */
|
973 | notDeepInclude<T>(haystack: ReadonlyArray<T> | ReadonlySet<T> | ReadonlyMap<any, T>, needle: T, message?: string): void;
|
974 |
|
975 | /**
|
976 | * Asserts that haystack does not includes needle. Deep equality is used.
|
977 | *
|
978 | * @type T Type of haystack.
|
979 | * @param haystack Object.
|
980 | * @param needle Potential subset of the haystack's properties.
|
981 | * @param message Message to display on error.
|
982 | */
|
983 | notDeepInclude<T>(haystack: T, needle: T extends WeakSet<any> ? never : Partial<T>, message?: string): void;
|
984 |
|
985 | /**
|
986 | * Asserts that ‘haystack’ includes ‘needle’. Can be used to assert the inclusion of a subset of properties in an object.
|
987 | *
|
988 | * Enables the use of dot- and bracket-notation for referencing nested properties.
|
989 | * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.Asserts that ‘haystack’ includes ‘needle’.
|
990 | * Can be used to assert the inclusion of a subset of properties in an object.
|
991 | * Enables the use of dot- and bracket-notation for referencing nested properties.
|
992 | * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.
|
993 | *
|
994 | * @param haystack
|
995 | * @param needle
|
996 | * @param message Message to display on error.
|
997 | */
|
998 | nestedInclude(haystack: any, needle: any, message?: string): void;
|
999 |
|
1000 | /**
|
1001 | * Asserts that ‘haystack’ does not include ‘needle’. Can be used to assert the absence of a subset of properties in an object.
|
1002 | *
|
1003 | * Enables the use of dot- and bracket-notation for referencing nested properties.
|
1004 | * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.Asserts that ‘haystack’ includes ‘needle’.
|
1005 | * Can be used to assert the inclusion of a subset of properties in an object.
|
1006 | * Enables the use of dot- and bracket-notation for referencing nested properties.
|
1007 | * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.
|
1008 | *
|
1009 | * @param haystack
|
1010 | * @param needle
|
1011 | * @param message Message to display on error.
|
1012 | */
|
1013 | notNestedInclude(haystack: any, needle: any, message?: string): void;
|
1014 |
|
1015 | /**
|
1016 | * 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
|
1017 | *
|
1018 | * Enables the use of dot- and bracket-notation for referencing nested properties.
|
1019 | * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.Asserts that ‘haystack’ includes ‘needle’.
|
1020 | * Can be used to assert the inclusion of a subset of properties in an object.
|
1021 | * Enables the use of dot- and bracket-notation for referencing nested properties.
|
1022 | * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.
|
1023 | *
|
1024 | * @param haystack
|
1025 | * @param needle
|
1026 | * @param message Message to display on error.
|
1027 | */
|
1028 | deepNestedInclude(haystack: any, needle: any, message?: string): void;
|
1029 |
|
1030 | /**
|
1031 | * 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.
|
1032 | *
|
1033 | * Enables the use of dot- and bracket-notation for referencing nested properties.
|
1034 | * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.Asserts that ‘haystack’ includes ‘needle’.
|
1035 | * Can be used to assert the inclusion of a subset of properties in an object.
|
1036 | * Enables the use of dot- and bracket-notation for referencing nested properties.
|
1037 | * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.
|
1038 | *
|
1039 | * @param haystack
|
1040 | * @param needle
|
1041 | * @param message Message to display on error.
|
1042 | */
|
1043 | notDeepNestedInclude(haystack: any, needle: any, message?: string): void;
|
1044 |
|
1045 | /**
|
1046 | * Asserts that ‘haystack’ includes ‘needle’. Can be used to assert the inclusion of a subset of properties in an object while ignoring inherited properties.
|
1047 | *
|
1048 | * @param haystack
|
1049 | * @param needle
|
1050 | * @param message Message to display on error.
|
1051 | */
|
1052 | ownInclude(haystack: any, needle: any, message?: string): void;
|
1053 |
|
1054 | /**
|
1055 | * Asserts that ‘haystack’ includes ‘needle’. Can be used to assert the absence of a subset of properties in an object while ignoring inherited properties.
|
1056 | *
|
1057 | * @param haystack
|
1058 | * @param needle
|
1059 | * @param message Message to display on error.
|
1060 | */
|
1061 | notOwnInclude(haystack: any, needle: any, message?: string): void;
|
1062 |
|
1063 | /**
|
1064 | * 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
|
1065 | *
|
1066 | * @param haystack
|
1067 | * @param needle
|
1068 | * @param message Message to display on error.
|
1069 | */
|
1070 | deepOwnInclude(haystack: any, needle: any, message?: string): void;
|
1071 |
|
1072 | /**
|
1073 | * 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.
|
1074 | *
|
1075 | * @param haystack
|
1076 | * @param needle
|
1077 | * @param message Message to display on error.
|
1078 | */
|
1079 | notDeepOwnInclude(haystack: any, needle: any, message?: string): void;
|
1080 |
|
1081 | /**
|
1082 | * Asserts that value matches the regular expression regexp.
|
1083 | *
|
1084 | * @param value Actual value.
|
1085 | * @param regexp Potential match of value.
|
1086 | * @param message Message to display on error.
|
1087 | */
|
1088 | match(value: string, regexp: RegExp, message?: string): void;
|
1089 |
|
1090 | /**
|
1091 | * Asserts that value does not match the regular expression regexp.
|
1092 | *
|
1093 | * @param value Actual value.
|
1094 | * @param regexp Potential match of value.
|
1095 | * @param message Message to display on error.
|
1096 | */
|
1097 | notMatch(expected: any, regexp: RegExp, message?: string): void;
|
1098 |
|
1099 | /**
|
1100 | * Asserts that object has a property named by property.
|
1101 | *
|
1102 | * @type T Type of object.
|
1103 | * @param object Container object.
|
1104 | * @param property Potential contained property of object.
|
1105 | * @param message Message to display on error.
|
1106 | */
|
1107 | property<T>(object: T, property: string , message?: string): void;
|
1108 |
|
1109 | /**
|
1110 | * Asserts that object has a property named by property.
|
1111 | *
|
1112 | * @type T Type of object.
|
1113 | * @param object Container object.
|
1114 | * @param property Potential contained property of object.
|
1115 | * @param message Message to display on error.
|
1116 | */
|
1117 | notProperty<T>(object: T, property: string , message?: string): void;
|
1118 |
|
1119 | /**
|
1120 | * Asserts that object has a property named by property, which can be a string
|
1121 | * using dot- and bracket-notation for deep reference.
|
1122 | *
|
1123 | * @type T Type of object.
|
1124 | * @param object Container object.
|
1125 | * @param property Potential contained property of object.
|
1126 | * @param message Message to display on error.
|
1127 | */
|
1128 | deepProperty<T>(object: T, property: string, message?: string): void;
|
1129 |
|
1130 | /**
|
1131 | * Asserts that object does not have a property named by property, which can be a
|
1132 | * string using dot- and bracket-notation for deep reference.
|
1133 | *
|
1134 | * @type T Type of object.
|
1135 | * @param object Container object.
|
1136 | * @param property Potential contained property of object.
|
1137 | * @param message Message to display on error.
|
1138 | */
|
1139 | notDeepProperty<T>(object: T, property: string, message?: string): void;
|
1140 |
|
1141 | /**
|
1142 | * Asserts that object has a property named by property with value given by value.
|
1143 | *
|
1144 | * @type T Type of object.
|
1145 | * @type V Type of value.
|
1146 | * @param object Container object.
|
1147 | * @param property Potential contained property of object.
|
1148 | * @param value Potential expected property value.
|
1149 | * @param message Message to display on error.
|
1150 | */
|
1151 | propertyVal<T, V>(object: T, property: string , value: V, message?: string): void;
|
1152 |
|
1153 | /**
|
1154 | * Asserts that object has a property named by property with value given by value.
|
1155 | *
|
1156 | * @type T Type of object.
|
1157 | * @type V Type of value.
|
1158 | * @param object Container object.
|
1159 | * @param property Potential contained property of object.
|
1160 | * @param value Potential expected property value.
|
1161 | * @param message Message to display on error.
|
1162 | */
|
1163 | notPropertyVal<T, V>(object: T, property: string , value: V, message?: string): void;
|
1164 |
|
1165 | /**
|
1166 | * Asserts that object has a property named by property, which can be a string
|
1167 | * using dot- and bracket-notation for deep reference.
|
1168 | *
|
1169 | * @type T Type of object.
|
1170 | * @type V Type of value.
|
1171 | * @param object Container object.
|
1172 | * @param property Potential contained property of object.
|
1173 | * @param value Potential expected property value.
|
1174 | * @param message Message to display on error.
|
1175 | */
|
1176 | deepPropertyVal<T, V>(object: T, property: string, value: V, message?: string): void;
|
1177 |
|
1178 | /**
|
1179 | * Asserts that object does not have a property named by property, which can be a
|
1180 | * string using dot- and bracket-notation for deep reference.
|
1181 | *
|
1182 | * @type T Type of object.
|
1183 | * @type V Type of value.
|
1184 | * @param object Container object.
|
1185 | * @param property Potential contained property of object.
|
1186 | * @param value Potential expected property value.
|
1187 | * @param message Message to display on error.
|
1188 | */
|
1189 | notDeepPropertyVal<T, V>(object: T, property: string, value: V, message?: string): void;
|
1190 |
|
1191 | /**
|
1192 | * Asserts that object has a length property with the expected value.
|
1193 | *
|
1194 | * @type T Type of object.
|
1195 | * @param object Container object.
|
1196 | * @param length Potential expected length of object.
|
1197 | * @param message Message to display on error.
|
1198 | */
|
1199 | lengthOf<T extends { readonly length?: number | undefined }>(object: T, length: number, message?: string): void;
|
1200 |
|
1201 | |
1202 |
|
1203 |
|
1204 |
|
1205 |
|
1206 |
|
1207 | throw(fn: () => void, message?: string): void;
|
1208 |
|
1209 | /**
|
1210 | * Asserts that function will throw an error with message matching regexp.
|
1211 | *
|
1212 | * @param fn Function that may throw.
|
1213 | * @param regExp Potential expected message match.
|
1214 | * @param message Message to display on error.
|
1215 | */
|
1216 | throw(fn: () => void, regExp: RegExp): void;
|
1217 |
|
1218 | /**
|
1219 | * Asserts that function will throw an error that is an instance of constructor.
|
1220 | *
|
1221 | * @param fn Function that may throw.
|
1222 | * @param constructor Potential expected error constructor.
|
1223 | * @param message Message to display on error.
|
1224 | */
|
1225 | throw(fn: () => void, constructor: ErrorConstructor, message?: string): void;
|
1226 |
|
1227 | /**
|
1228 | * Asserts that function will throw an error that is an instance of constructor
|
1229 | * and an error with message matching regexp.
|
1230 | *
|
1231 | * @param fn Function that may throw.
|
1232 | * @param constructor Potential expected error constructor.
|
1233 | * @param message Message to display on error.
|
1234 | */
|
1235 | throw(fn: () => void, constructor: ErrorConstructor, regExp: RegExp): void;
|
1236 |
|
1237 | /**
|
1238 | * Asserts that fn will throw an error.
|
1239 | *
|
1240 | * @param fn Function that may throw.
|
1241 | * @param message Message to display on error.
|
1242 | */
|
1243 | throws(fn: () => void, message?: string): void;
|
1244 |
|
1245 | /**
|
1246 | * Asserts that function will throw an error with message matching regexp.
|
1247 | *
|
1248 | * @param fn Function that may throw.
|
1249 | * @param errType Potential expected message match or error constructor.
|
1250 | * @param message Message to display on error.
|
1251 | */
|
1252 | throws(fn: () => void, errType: RegExp | ErrorConstructor, message?: string): void;
|
1253 |
|
1254 | /**
|
1255 | * Asserts that function will throw an error that is an instance of constructor
|
1256 | * and an error with message matching regexp.
|
1257 | *
|
1258 | * @param fn Function that may throw.
|
1259 | * @param constructor Potential expected error constructor.
|
1260 | * @param message Message to display on error.
|
1261 | */
|
1262 | throws(fn: () => void, constructor: ErrorConstructor, regExp: RegExp): void;
|
1263 |
|
1264 | /**
|
1265 | * Asserts that fn will throw an error.
|
1266 | *
|
1267 | * @param fn Function that may throw.
|
1268 | * @param message Message to display on error.
|
1269 | */
|
1270 | Throw(fn: () => void, message?: string): void;
|
1271 |
|
1272 | /**
|
1273 | * Asserts that function will throw an error with message matching regexp.
|
1274 | *
|
1275 | * @param fn Function that may throw.
|
1276 | * @param regExp Potential expected message match.
|
1277 | * @param message Message to display on error.
|
1278 | */
|
1279 | Throw(fn: () => void, regExp: RegExp): void;
|
1280 |
|
1281 | /**
|
1282 | * Asserts that function will throw an error that is an instance of constructor.
|
1283 | *
|
1284 | * @param fn Function that may throw.
|
1285 | * @param constructor Potential expected error constructor.
|
1286 | * @param message Message to display on error.
|
1287 | */
|
1288 | Throw(fn: () => void, constructor: ErrorConstructor, message?: string): void;
|
1289 |
|
1290 | /**
|
1291 | * Asserts that function will throw an error that is an instance of constructor
|
1292 | * and an error with message matching regexp.
|
1293 | *
|
1294 | * @param fn Function that may throw.
|
1295 | * @param constructor Potential expected error constructor.
|
1296 | * @param message Message to display on error.
|
1297 | */
|
1298 | Throw(fn: () => void, constructor: ErrorConstructor, regExp: RegExp): void;
|
1299 |
|
1300 | /**
|
1301 | * Asserts that fn will not throw an error.
|
1302 | *
|
1303 | * @param fn Function that may throw.
|
1304 | * @param message Message to display on error.
|
1305 | */
|
1306 | doesNotThrow(fn: () => void, message?: string): void;
|
1307 |
|
1308 | /**
|
1309 | * Asserts that function will throw an error with message matching regexp.
|
1310 | *
|
1311 | * @param fn Function that may throw.
|
1312 | * @param regExp Potential expected message match.
|
1313 | * @param message Message to display on error.
|
1314 | */
|
1315 | doesNotThrow(fn: () => void, regExp: RegExp): void;
|
1316 |
|
1317 | /**
|
1318 | * Asserts that function will throw an error that is an instance of constructor.
|
1319 | *
|
1320 | * @param fn Function that may throw.
|
1321 | * @param constructor Potential expected error constructor.
|
1322 | * @param message Message to display on error.
|
1323 | */
|
1324 | doesNotThrow(fn: () => void, constructor: ErrorConstructor, message?: string): void;
|
1325 |
|
1326 | /**
|
1327 | * Asserts that function will throw an error that is an instance of constructor
|
1328 | * and an error with message matching regexp.
|
1329 | *
|
1330 | * @param fn Function that may throw.
|
1331 | * @param constructor Potential expected error constructor.
|
1332 | * @param message Message to display on error.
|
1333 | */
|
1334 | doesNotThrow(fn: () => void, constructor: ErrorConstructor, regExp: RegExp): void;
|
1335 |
|
1336 | /**
|
1337 | * Compares two values using operator.
|
1338 | *
|
1339 | * @param val1 Left value during comparison.
|
1340 | * @param operator Comparison operator.
|
1341 | * @param val2 Right value during comparison.
|
1342 | * @param message Message to display on error.
|
1343 | */
|
1344 | operator(val1: OperatorComparable, operator: Operator, val2: OperatorComparable, message?: string): void;
|
1345 |
|
1346 | /**
|
1347 | * Asserts that the target is equal to expected, to within a +/- delta range.
|
1348 | *
|
1349 | * @param actual Actual value
|
1350 | * @param expected Potential expected value.
|
1351 | * @param delta Maximum differenced between values.
|
1352 | * @param message Message to display on error.
|
1353 | */
|
1354 | closeTo(actual: number, expected: number, delta: number, message?: string): void;
|
1355 |
|
1356 | /**
|
1357 | * Asserts that the target is equal to expected, to within a +/- delta range.
|
1358 | *
|
1359 | * @param actual Actual value
|
1360 | * @param expected Potential expected value.
|
1361 | * @param delta Maximum differenced between values.
|
1362 | * @param message Message to display on error.
|
1363 | */
|
1364 | approximately(act: number, exp: number, delta: number, message?: string): void;
|
1365 |
|
1366 | /**
|
1367 | * Asserts that set1 and set2 have the same members. Order is not take into account.
|
1368 | *
|
1369 | * @type T Type of set values.
|
1370 | * @param set1 Actual set of values.
|
1371 | * @param set2 Potential expected set of values.
|
1372 | * @param message Message to display on error.
|
1373 | */
|
1374 | sameMembers<T>(set1: T[], set2: T[], message?: string): void;
|
1375 |
|
1376 | /**
|
1377 | * Asserts that set1 and set2 have the same members using deep equality checking.
|
1378 | * Order is not take into account.
|
1379 | *
|
1380 | * @type T Type of set values.
|
1381 | * @param set1 Actual set of values.
|
1382 | * @param set2 Potential expected set of values.
|
1383 | * @param message Message to display on error.
|
1384 | */
|
1385 | sameDeepMembers<T>(set1: T[], set2: T[], message?: string): void;
|
1386 |
|
1387 | /**
|
1388 | * Asserts that set1 and set2 have the same members in the same order.
|
1389 | * Uses a strict equality check (===).
|
1390 | *
|
1391 | * @type T Type of set values.
|
1392 | * @param set1 Actual set of values.
|
1393 | * @param set2 Potential expected set of values.
|
1394 | * @param message Message to display on error.
|
1395 | */
|
1396 | sameOrderedMembers<T>(set1: T[], set2: T[], message?: string): void;
|
1397 |
|
1398 | /**
|
1399 | * Asserts that set1 and set2 don’t have the same members in the same order.
|
1400 | * Uses a strict equality check (===).
|
1401 | *
|
1402 | * @type T Type of set values.
|
1403 | * @param set1 Actual set of values.
|
1404 | * @param set2 Potential expected set of values.
|
1405 | * @param message Message to display on error.
|
1406 | */
|
1407 | notSameOrderedMembers<T>(set1: T[], set2: T[], message?: string): void;
|
1408 |
|
1409 | /**
|
1410 | * Asserts that set1 and set2 have the same members in the same order.
|
1411 | * Uses a deep equality check.
|
1412 | *
|
1413 | * @type T Type of set values.
|
1414 | * @param set1 Actual set of values.
|
1415 | * @param set2 Potential expected set of values.
|
1416 | * @param message Message to display on error.
|
1417 | */
|
1418 | sameDeepOrderedMembers<T>(set1: T[], set2: T[], message?: string): void;
|
1419 |
|
1420 | /**
|
1421 | * Asserts that set1 and set2 don’t have the same members in the same order.
|
1422 | * Uses a deep equality check.
|
1423 | *
|
1424 | * @type T Type of set values.
|
1425 | * @param set1 Actual set of values.
|
1426 | * @param set2 Potential expected set of values.
|
1427 | * @param message Message to display on error.
|
1428 | */
|
1429 | notSameDeepOrderedMembers<T>(set1: T[], set2: T[], message?: string): void;
|
1430 |
|
1431 | /**
|
1432 | * Asserts that subset is included in superset in the same order beginning with the first element in superset.
|
1433 | * Uses a strict equality check (===).
|
1434 | *
|
1435 | * @type T Type of set values.
|
1436 | * @param superset Actual set of values.
|
1437 | * @param subset Potential contained set of values.
|
1438 | * @param message Message to display on error.
|
1439 | */
|
1440 | includeOrderedMembers<T>(superset: T[], subset: T[], message?: string): void;
|
1441 |
|
1442 | /**
|
1443 | * Asserts that subset isn’t included in superset in the same order beginning with the first element in superset.
|
1444 | * Uses a strict equality check (===).
|
1445 | *
|
1446 | * @type T Type of set values.
|
1447 | * @param superset Actual set of values.
|
1448 | * @param subset Potential contained set of values.
|
1449 | * @param message Message to display on error.
|
1450 | */
|
1451 | notIncludeOrderedMembers<T>(superset: T[], subset: T[], message?: string): void;
|
1452 |
|
1453 | /**
|
1454 | * Asserts that subset is included in superset in the same order beginning with the first element in superset.
|
1455 | * Uses a deep equality check.
|
1456 | *
|
1457 | * @type T Type of set values.
|
1458 | * @param superset Actual set of values.
|
1459 | * @param subset Potential contained set of values.
|
1460 | * @param message Message to display on error.
|
1461 | */
|
1462 | includeDeepOrderedMembers<T>(superset: T[], subset: T[], message?: string): void;
|
1463 |
|
1464 | /**
|
1465 | * Asserts that subset isn’t included in superset in the same order beginning with the first element in superset.
|
1466 | * Uses a deep equality check.
|
1467 | *
|
1468 | * @type T Type of set values.
|
1469 | * @param superset Actual set of values.
|
1470 | * @param subset Potential contained set of values.
|
1471 | * @param message Message to display on error.
|
1472 | */
|
1473 | notIncludeDeepOrderedMembers<T>(superset: T[], subset: T[], message?: string): void;
|
1474 |
|
1475 | /**
|
1476 | * Asserts that subset is included in superset. Order is not take into account.
|
1477 | *
|
1478 | * @type T Type of set values.
|
1479 | * @param superset Actual set of values.
|
1480 | * @param subset Potential contained set of values.
|
1481 | * @param message Message to display on error.
|
1482 | */
|
1483 | includeMembers<T>(superset: T[], subset: T[], message?: string): void;
|
1484 |
|
1485 | /**
|
1486 | * Asserts that subset isn’t included in superset in any order.
|
1487 | * Uses a strict equality check (===). Duplicates are ignored.
|
1488 | *
|
1489 | * @type T Type of set values.
|
1490 | * @param superset Actual set of values.
|
1491 | * @param subset Potential not contained set of values.
|
1492 | * @param message Message to display on error.
|
1493 | */
|
1494 | notIncludeMembers<T>(superset: T[], subset: T[], message?: string): void;
|
1495 |
|
1496 | /**
|
1497 | * Asserts that subset is included in superset using deep equality checking.
|
1498 | * Order is not take into account.
|
1499 | *
|
1500 | * @type T Type of set values.
|
1501 | * @param superset Actual set of values.
|
1502 | * @param subset Potential contained set of values.
|
1503 | * @param message Message to display on error.
|
1504 | */
|
1505 | includeDeepMembers<T>(superset: T[], subset: T[], message?: string): void;
|
1506 |
|
1507 | /**
|
1508 | * Asserts that non-object, non-array value inList appears in the flat array list.
|
1509 | *
|
1510 | * @type T Type of list values.
|
1511 | * @param inList Value expected to be in the list.
|
1512 | * @param list List of values.
|
1513 | * @param message Message to display on error.
|
1514 | */
|
1515 | oneOf<T>(inList: T, list: T[], message?: string): void;
|
1516 |
|
1517 | /**
|
1518 | * Asserts that a function changes the value of a property.
|
1519 | *
|
1520 | * @type T Type of object.
|
1521 | * @param modifier Function to run.
|
1522 | * @param object Container object.
|
1523 | * @param property Property of object expected to be modified.
|
1524 | * @param message Message to display on error.
|
1525 | */
|
1526 | changes<T>(modifier: Function, object: T, property: string , message?: string): void;
|
1527 |
|
1528 | /**
|
1529 | * Asserts that a function does not change the value of a property.
|
1530 | *
|
1531 | * @type T Type of object.
|
1532 | * @param modifier Function to run.
|
1533 | * @param object Container object.
|
1534 | * @param property Property of object expected not to be modified.
|
1535 | * @param message Message to display on error.
|
1536 | */
|
1537 | doesNotChange<T>(modifier: Function, object: T, property: string , message?: string): void;
|
1538 |
|
1539 | /**
|
1540 | * Asserts that a function increases an object property.
|
1541 | *
|
1542 | * @type T Type of object.
|
1543 | * @param modifier Function to run.
|
1544 | * @param object Container object.
|
1545 | * @param property Property of object expected to be increased.
|
1546 | * @param message Message to display on error.
|
1547 | */
|
1548 | increases<T>(modifier: Function, object: T, property: string , message?: string): void;
|
1549 |
|
1550 | /**
|
1551 | * Asserts that a function does not increase an object property.
|
1552 | *
|
1553 | * @type T Type of object.
|
1554 | * @param modifier Function to run.
|
1555 | * @param object Container object.
|
1556 | * @param property Property of object expected not to be increased.
|
1557 | * @param message Message to display on error.
|
1558 | */
|
1559 | doesNotIncrease<T>(modifier: Function, object: T, property: string , message?: string): void;
|
1560 |
|
1561 | /**
|
1562 | * Asserts that a function decreases an object property.
|
1563 | *
|
1564 | * @type T Type of object.
|
1565 | * @param modifier Function to run.
|
1566 | * @param object Container object.
|
1567 | * @param property Property of object expected to be decreased.
|
1568 | * @param message Message to display on error.
|
1569 | */
|
1570 | decreases<T>(modifier: Function, object: T, property: string , message?: string): void;
|
1571 |
|
1572 | /**
|
1573 | * Asserts that a function does not decrease an object property.
|
1574 | *
|
1575 | * @type T Type of object.
|
1576 | * @param modifier Function to run.
|
1577 | * @param object Container object.
|
1578 | * @param property Property of object expected not to be decreased.
|
1579 | * @param message Message to display on error.
|
1580 | */
|
1581 | doesNotDecrease<T>(modifier: Function, object: T, property: string , message?: string): void;
|
1582 |
|
1583 | /**
|
1584 | * Asserts if value is not a false value, and throws if it is a true value.
|
1585 | *
|
1586 | * @type T Type of object.
|
1587 | * @param object Actual value.
|
1588 | * @param message Message to display on error.
|
1589 | * @remarks This is added to allow for chai to be a drop-in replacement for
|
1590 | * Node’s assert class.
|
1591 | */
|
1592 | ifError<T>(object: T, message?: string): void;
|
1593 |
|
1594 | /**
|
1595 | * Asserts that object is extensible (can have new properties added to it).
|
1596 | *
|
1597 | * @type T Type of object
|
1598 | * @param object Actual value.
|
1599 | * @param message Message to display on error.
|
1600 | */
|
1601 | isExtensible<T>(object: T, message?: string): void;
|
1602 |
|
1603 | /**
|
1604 | * Asserts that object is extensible (can have new properties added to it).
|
1605 | *
|
1606 | * @type T Type of object
|
1607 | * @param object Actual value.
|
1608 | * @param message Message to display on error.
|
1609 | */
|
1610 | extensible<T>(object: T, message?: string): void;
|
1611 |
|
1612 | /**
|
1613 | * Asserts that object is not extensible.
|
1614 | *
|
1615 | * @type T Type of object
|
1616 | * @param object Actual value.
|
1617 | * @param message Message to display on error.
|
1618 | */
|
1619 | isNotExtensible<T>(object: T, message?: string): void;
|
1620 |
|
1621 | /**
|
1622 | * Asserts that object is not extensible.
|
1623 | *
|
1624 | * @type T Type of object
|
1625 | * @param object Actual value.
|
1626 | * @param message Message to display on error.
|
1627 | */
|
1628 | notExtensible<T>(object: T, message?: string): void;
|
1629 |
|
1630 | /**
|
1631 | * Asserts that object is sealed (can have new properties added to it
|
1632 | * and its existing properties cannot be removed).
|
1633 | *
|
1634 | * @type T Type of object
|
1635 | * @param object Actual value.
|
1636 | * @param message Message to display on error.
|
1637 | */
|
1638 | isSealed<T>(object: T, message?: string): void;
|
1639 |
|
1640 | /**
|
1641 | * Asserts that object is sealed (can have new properties added to it
|
1642 | * and its existing properties cannot be removed).
|
1643 | *
|
1644 | * @type T Type of object
|
1645 | * @param object Actual value.
|
1646 | * @param message Message to display on error.
|
1647 | */
|
1648 | sealed<T>(object: T, message?: string): void;
|
1649 |
|
1650 | /**
|
1651 | * Asserts that object is not sealed.
|
1652 | *
|
1653 | * @type T Type of object
|
1654 | * @param object Actual value.
|
1655 | * @param message Message to display on error.
|
1656 | */
|
1657 | isNotSealed<T>(object: T, message?: string): void;
|
1658 |
|
1659 | /**
|
1660 | * Asserts that object is not sealed.
|
1661 | *
|
1662 | * @type T Type of object
|
1663 | * @param object Actual value.
|
1664 | * @param message Message to display on error.
|
1665 | */
|
1666 | notSealed<T>(object: T, message?: string): void;
|
1667 |
|
1668 | /**
|
1669 | * Asserts that object is frozen (cannot have new properties added to it
|
1670 | * and its existing properties cannot be removed).
|
1671 | *
|
1672 | * @type T Type of object
|
1673 | * @param object Actual value.
|
1674 | * @param message Message to display on error.
|
1675 | */
|
1676 | isFrozen<T>(object: T, message?: string): void;
|
1677 |
|
1678 | /**
|
1679 | * Asserts that object is frozen (cannot have new properties added to it
|
1680 | * and its existing properties cannot be removed).
|
1681 | *
|
1682 | * @type T Type of object
|
1683 | * @param object Actual value.
|
1684 | * @param message Message to display on error.
|
1685 | */
|
1686 | frozen<T>(object: T, message?: string): void;
|
1687 |
|
1688 | /**
|
1689 | * Asserts that object is not frozen (cannot have new properties added to it
|
1690 | * and its existing properties cannot be removed).
|
1691 | *
|
1692 | * @type T Type of object
|
1693 | * @param object Actual value.
|
1694 | * @param message Message to display on error.
|
1695 | */
|
1696 | isNotFrozen<T>(object: T, message?: string): void;
|
1697 |
|
1698 | /**
|
1699 | * Asserts that object is not frozen (cannot have new properties added to it
|
1700 | * and its existing properties cannot be removed).
|
1701 | *
|
1702 | * @type T Type of object
|
1703 | * @param object Actual value.
|
1704 | * @param message Message to display on error.
|
1705 | */
|
1706 | notFrozen<T>(object: T, message?: string): void;
|
1707 |
|
1708 | /**
|
1709 | * Asserts that the target does not contain any values. For arrays and
|
1710 | * strings, it checks the length property. For Map and Set instances, it
|
1711 | * checks the size property. For non-function objects, it gets the count
|
1712 | * of own enumerable string keys.
|
1713 | *
|
1714 | * @type T Type of object
|
1715 | * @param object Actual value.
|
1716 | * @param message Message to display on error.
|
1717 | */
|
1718 | isEmpty<T>(object: T, message?: string): void;
|
1719 |
|
1720 | /**
|
1721 | * Asserts that the target contains values. For arrays and strings, it checks
|
1722 | * the length property. For Map and Set instances, it checks the size property.
|
1723 | * For non-function objects, it gets the count of own enumerable string keys.
|
1724 | *
|
1725 | * @type T Type of object.
|
1726 | * @param object Object to test.
|
1727 | * @param message Message to display on error.
|
1728 | */
|
1729 | isNotEmpty<T>(object: T, message?: string): void;
|
1730 |
|
1731 | /**
|
1732 | * Asserts that `object` has at least one 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 | hasAnyKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
|
1742 |
|
1743 | /**
|
1744 | * Asserts that `object` has all and only all of the `keys` provided.
|
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 | hasAllKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
|
1754 |
|
1755 | /**
|
1756 | * Asserts that `object` has all of the `keys` provided but may have more keys not listed.
|
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 | containsAllKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
|
1766 |
|
1767 | /**
|
1768 | * Asserts that `object` has none 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 | doesNotHaveAnyKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
|
1778 |
|
1779 | /**
|
1780 | * Asserts that `object` does not have at least one of the `keys` provided.
|
1781 | * You can also provide a single object instead of a `keys` array and its keys
|
1782 | * will be used as the expected set of keys.
|
1783 | *
|
1784 | * @type T Type of object.
|
1785 | * @param object Object to test.
|
1786 | * @param keys Keys to check
|
1787 | * @param message Message to display on error.
|
1788 | */
|
1789 | doesNotHaveAllKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
|
1790 |
|
1791 | /**
|
1792 | * Asserts that `object` has at least one of the `keys` provided.
|
1793 | * Since Sets and Maps can have objects as keys you can use this assertion to perform
|
1794 | * a deep comparison.
|
1795 | * You can also provide a single object instead of a `keys` array and its keys
|
1796 | * will be used as the expected set of keys.
|
1797 | *
|
1798 | * @type T Type of object.
|
1799 | * @param object Object to test.
|
1800 | * @param keys Keys to check
|
1801 | * @param message Message to display on error.
|
1802 | */
|
1803 | hasAnyDeepKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
|
1804 |
|
1805 | /**
|
1806 | * Asserts that `object` has all and only all of the `keys` provided.
|
1807 | * Since Sets and Maps can have objects as keys you can use this assertion to perform
|
1808 | * a deep comparison.
|
1809 | * You can also provide a single object instead of a `keys` array and its keys
|
1810 | * will be used as the expected set of keys.
|
1811 | *
|
1812 | * @type T Type of object.
|
1813 | * @param object Object to test.
|
1814 | * @param keys Keys to check
|
1815 | * @param message Message to display on error.
|
1816 | */
|
1817 | hasAllDeepKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
|
1818 |
|
1819 | /**
|
1820 | * Asserts that `object` contains all of the `keys` provided.
|
1821 | * Since Sets and Maps can have objects as keys you can use this assertion to perform
|
1822 | * a deep comparison.
|
1823 | * You can also provide a single object instead of a `keys` array and its keys
|
1824 | * will be used as the expected set of keys.
|
1825 | *
|
1826 | * @type T Type of object.
|
1827 | * @param object Object to test.
|
1828 | * @param keys Keys to check
|
1829 | * @param message Message to display on error.
|
1830 | */
|
1831 | containsAllDeepKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
|
1832 |
|
1833 | /**
|
1834 | * Asserts that `object` contains all of the `keys` provided.
|
1835 | * Since Sets and Maps can have objects as keys you can use this assertion to perform
|
1836 | * a deep comparison.
|
1837 | * You can also provide a single object instead of a `keys` array and its keys
|
1838 | * will be used as the expected set of keys.
|
1839 | *
|
1840 | * @type T Type of object.
|
1841 | * @param object Object to test.
|
1842 | * @param keys Keys to check
|
1843 | * @param message Message to display on error.
|
1844 | */
|
1845 | doesNotHaveAnyDeepKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
|
1846 |
|
1847 | /**
|
1848 | * Asserts that `object` contains all of the `keys` provided.
|
1849 | * Since Sets and Maps can have objects as keys you can use this assertion to perform
|
1850 | * a deep comparison.
|
1851 | * You can also provide a single object instead of a `keys` array and its keys
|
1852 | * will be used as the expected set of keys.
|
1853 | *
|
1854 | * @type T Type of object.
|
1855 | * @param object Object to test.
|
1856 | * @param keys Keys to check
|
1857 | * @param message Message to display on error.
|
1858 | */
|
1859 | doesNotHaveAllDeepKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
|
1860 |
|
1861 | /**
|
1862 | * Asserts that object has a direct or inherited property named by property,
|
1863 | * which can be a string using dot- and bracket-notation for nested reference.
|
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 | nestedProperty<T>(object: T, property: string, message?: string): void;
|
1871 |
|
1872 | /**
|
1873 | * Asserts that object does not have a property named by property,
|
1874 | * which can be a string using dot- and bracket-notation for nested reference.
|
1875 | * The property cannot exist on the object nor anywhere in its prototype chain.
|
1876 | *
|
1877 | * @type T Type of object.
|
1878 | * @param object Object to test.
|
1879 | * @param property Property to test.
|
1880 | * @param message Message to display on error.
|
1881 | */
|
1882 | notNestedProperty<T>(object: T, property: string, message?: string): void;
|
1883 |
|
1884 | /**
|
1885 | * Asserts that object has 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 | nestedPropertyVal<T>(object: T, property: string, value: any, message?: string): void;
|
1895 |
|
1896 | /**
|
1897 | * Asserts that object does not have a property named by property with value given by value.
|
1898 | * property can use dot- and bracket-notation for nested reference. Uses a strict 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 | notNestedPropertyVal<T>(object: T, property: string, value: any, message?: string): void;
|
1907 |
|
1908 | /**
|
1909 | * Asserts that object has a property named by property with a 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 | deepNestedPropertyVal<T>(object: T, property: string, value: any, message?: string): void;
|
1919 |
|
1920 | /**
|
1921 | * Asserts that object does not have a property named by property with value given by value.
|
1922 | * property can use dot- and bracket-notation for nested reference. Uses a deep equality check.
|
1923 | *
|
1924 | * @type T Type of object.
|
1925 | * @param object Object to test.
|
1926 | * @param property Property to test.
|
1927 | * @param value Value to test.
|
1928 | * @param message Message to display on error.
|
1929 | */
|
1930 | notDeepNestedPropertyVal<T>(object: T, property: string, value: any, message?: string): void;
|
1931 | }
|
1932 |
|
1933 | export interface Config {
|
1934 | /**
|
1935 | * Default: false
|
1936 | */
|
1937 | includeStack: boolean;
|
1938 |
|
1939 | /**
|
1940 | * Default: true
|
1941 | */
|
1942 | showDiff: boolean;
|
1943 |
|
1944 | /**
|
1945 | * Default: 40
|
1946 | */
|
1947 | truncateThreshold: number;
|
1948 |
|
1949 | /**
|
1950 | * Default: true
|
1951 | */
|
1952 | useProxy: boolean;
|
1953 |
|
1954 | /**
|
1955 | * Default: ['then', 'catch', 'inspect', 'toJSON']
|
1956 | */
|
1957 | proxyExcludedKeys: string[];
|
1958 | }
|
1959 |
|
1960 | export class AssertionError {
|
1961 | constructor(message: string, _props?: any, ssf?: Function);
|
1962 | name: string;
|
1963 | message: string;
|
1964 | showDiff: boolean;
|
1965 | stack: string;
|
1966 | }
|
1967 | }
|
1968 |
|
1969 | declare const chai: Chai.ChaiStatic;
|
1970 |
|
1971 | declare module "chai" {
|
1972 | export = chai;
|
1973 | }
|
1974 |
|
1975 | interface Object {
|
1976 | should: Chai.Assertion;
|
1977 | }
|
1978 |
|
\ | No newline at end of file |