forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jshamcrest.d.ts
1144 lines (977 loc) · 37 KB
/
jshamcrest.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Type definitions for JsHamcrest 0.7.0
// Project: https://github.com/danielfm/jshamcrest/
// Definitions by: David Harkness <https://github.com/dharkness>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/**
* Top-level module for the JsHamcrest matcher library.
*
* @author Daniel Martins
*/
declare module JsHamcrest {
/**
* Library version.
*/
export var version: string;
//
// Description
//
/**
* Defines the method for describing the object to a description.
*/
interface DescribeTo {
(description: Description): void;
}
/**
* Defines the method for describing a value to a description.
*/
interface DescribeValueTo {
(value: any, description: Description): void;
}
/**
* Defines a method for describing the object implementing this interface to a description.
*
* TODO Remove? Not actually declared by JsHamcrest, but useful for type-checking in Description methods
*/
export interface SelfDescribing {
describeTo: DescribeTo;
}
/**
* Builder for a textual description.
*/
export class Description {
/**
* Appends text to this description.
*
* @param text Text to append to this description
* @return {Description} Itself for method chaining
*/
append(text: any): Description;
/**
* Appends the description of a self describing object to this description.
*
* @param selfDescribingObject Any object that has a describeTo() function that accepts a JsHamcrest.Description object as argument
* @return {Description} Itself for method chaining
*/
appendDescriptionOf(selfDescribingObject: SelfDescribing): Description;
/**
* Appends the description of several self describing objects to this description.
*
* @param start Start string
* @param separator Separator string
* @param end End string
* @param list Array of self describing objects. These objects must have a describeTo() function that accepts a JsHamcrest.Description object as argument
* @return {Description} Itself for method chaining
*/
appendList(start: string, separator: string, end: string, list: any[]): Description;
/**
* Appends a JavaScript language’s literal to this description.
*
* @param literal Literal to append to this description
* @return {Description} Itself for method chaining
*/
appendLiteral(literal: any): Description;
/**
* Appends an array of values to this description.
*
* @param start Start string
* @param separator Separator string
* @param end End string
* @param list Array of values to be described to this description
* @return {Description} Itself for method chaining
*/
appendValueList(start: string, separator: string, end: string, list: SelfDescribing[]): Description;
/**
* Gets the current content of this description.
*
* @return {string} Current content of this description
*/
get(): string;
}
//
// Matcher
//
/**
* Defines the method for testing the matcher against an actual value.
*/
interface Matches {
(value: any): boolean;
}
/**
* Defines the minimal interface for every matcher.
*
* FIXME Remove since isMatcher tests for SimpleMatcher :(
*/
export interface Matcher extends SelfDescribing {
matches: Matches;
describeValueTo: DescribeValueTo;
}
/**
* Defines the configurable methods for declaring a new matcher using JsHamcrest.SimpleMatcher.
*/
interface MatcherConfig {
matches: Matches;
describeTo: DescribeTo;
describeValueTo?: DescribeValueTo;
}
/**
* Defines a matcher that relies on the external functions provided by the caller in order to shape the current matching logic.
*/
export class SimpleMatcher implements Matcher {
matches: Matches;
describeTo: DescribeTo;
describeValueTo: DescribeValueTo;
constructor(config: MatcherConfig);
}
/**
* Defines a composite matcher, that is, a matcher that wraps several matchers into one.
*/
export class CombinableMatcher extends SimpleMatcher {
/**
* Wraps this matcher and the given matcher using JsHamcrest.Matchers.allOf().
*
* @param matcherOrValue Instance of JsHamcrest.SimpleMatcher or a value
* @return {CombinableMatcher} Instance of JsHamcrest.CombinableMatcher
*/
and(matcherOrValue: any): CombinableMatcher;
/**
* Wraps this matcher and the given matcher using JsHamcrest.Matchers.anyOf().
*
* @param matcherOrValue Instance of JsHamcrest.SimpleMatcher or a value
* @return {CombinableMatcher} Instance of JsHamcrest.CombinableMatcher
*/
or(matcherOrValue: any): CombinableMatcher;
}
//
// Helpers
//
/**
* Checks if the given object is a matcher or not.
*
* @param obj Object to check
* @return {boolean} True if the given object is a matcher; false otherwise
*/
export function isMatcher(obj: any): boolean;
/**
* Delegate function, useful when used to create a matcher that has a value-equalTo semantic.
*
* @param factory Creates a new matcher that delegates to the passed/wrapped matcherOrValue
* @return {function(*): Matcher} Wraps the value with equalTo before passing to factory
*/
export function EqualTo(factory: (matcher: Matcher) => Matcher): (matcherOrValue: any) => Matcher;
/**
* Provides the assertion, filtering, and currying methods.
*/
module Operators {
/**
* Defines the options accepted by assert().
*/
interface AssertOptions {
message?: any;
pass?: (description: string) => void;
fail?: (description: string) => void;
}
/**
* Fails if the actual value does not match the matcher.
*
* @param actual Value to test against the matcher
* @param matcherOrValue Applied to the value; wrapped with equalTo() if not a matcher
* @param options Provides message and pass/fail handlers
* @return {JsHamcrest.Description} Contains the message, actual value, matcher, and result
*/
export function assert(actual: any, matcherOrValue?: any, options?: AssertOptions): JsHamcrest.Description;
/**
* Returns those items of the array for which matcher matches.
*
* @param array The values to filter
* @param matcherOrValue Applied to each value
* @return {Array.<*>} Contains all values from array matched by the matcher in the original order
*/
export function filter(array: any[], matcherOrValue: any): any[];
/**
* Delegate function, useful when used along with raises() and raisesAnything().
*
* @param func Function to delegate to
* @param args Passed to func
* @return {function(): *} A function that calls func with args and returns its result
*/
export function callTo(func: (...args: any[]) => any, ...args: any[]): () => any;
}
/**
* Defines all of the built-in matchers grouped into five categories.
*/
module Matchers {
//
// Collection Matchers
//
/**
* The length of the actual value must be zero.
*
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function empty(): JsHamcrest.SimpleMatcher;
/**
* The actual value should be an array and matcherOrValue must match all items.
*
* @param matcherOrValue Instance of JsHamcrest.SimpleMatcher or a value
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function everyItem(matcherOrValue: any): JsHamcrest.SimpleMatcher;
/**
* The actual value should be an array and it must contain at least one value that matches matcherOrValue.
*
* @param matcherOrValue Instance of JsHamcrest.SimpleMatcher or a value
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function hasItem(matcherOrValue: any): JsHamcrest.SimpleMatcher;
/**
* The actual value should be an array and matchersOrValues must match at least one item.
*
* @param matchersOrValues Instances of JsHamcrest.SimpleMatcher and/or values
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function hasItems(...matchersOrValues: any[]): JsHamcrest.SimpleMatcher;
/**
* The length of the actual value must match matcherOrValue.
*
* @param matcherOrValue Instance of JsHamcrest.SimpleMatcher or a value
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function hasSize(matcherOrValue: any): JsHamcrest.SimpleMatcher;
/**
* The given array or arguments must contain the actual value.
*
* @param items Array or list of values
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function isIn(...items: any[]): JsHamcrest.SimpleMatcher;
/**
* Alias to isIn() function.
*
* @param items Array or list of values
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function oneOf(...items: any[]): JsHamcrest.SimpleMatcher;
//
// Core Matchers
//
/**
* All matchesOrValues must match the actual value. This matcher behaves pretty much like the JavaScript && (and) operator.
*
* @param matchersOrValues Instances of JsHamcrest.SimpleMatcher and/or values
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function allOf(...matchersOrValues: any[]): JsHamcrest.SimpleMatcher;
/**
* At least one of the matchersOrValues should match the actual value. This matcher behaves pretty much like the JavaScript || (or) operator.
*
* @param matchersOrValues Instances of JsHamcrest.SimpleMatcher and/or values
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function anyOf(...matchersOrValues: any[]): JsHamcrest.SimpleMatcher;
/**
* Useless always-match matcher.
*
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function anything(): JsHamcrest.SimpleMatcher;
/**
* Combinable matcher where the actual value must match all the given matchers or values.
*
* @param matcherOrValue Instance of JsHamcrest.SimpleMatcher or a value
* @return {JsHamcrest.CombinableMatcher} Instance of JsHamcrest.CombinableMatcher
*/
export function both(matcherOrValue: any): JsHamcrest.CombinableMatcher;
/**
* Combinable matcher where the actual value must match at least one of the given matchers or values.
*
* @param matcherOrValue Instance of JsHamcrest.SimpleMatcher or a value
* @return {JsHamcrest.CombinableMatcher} Instance of JsHamcrest.CombinableMatcher
*/
export function either(matcherOrValue: any): JsHamcrest.CombinableMatcher;
/**
* The actual value must be equal to expected.
*
* @param expected Expected value
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function equalTo(expected: any): JsHamcrest.SimpleMatcher;
/**
* Delegate-only matcher frequently used to improve readability.
*
* @param matcherOrValue Instance of JsHamcrest.SimpleMatcher or a value
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function is(matcherOrValue: any): JsHamcrest.SimpleMatcher;
/**
* The actual value must be null or undefined.
*
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function nil(): JsHamcrest.SimpleMatcher;
/**
* The actual value must not match matcherOrValue.
*
* @param matcherOrValue Instance of JsHamcrest.SimpleMatcher or a value
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function not(matcherOrValue: any): JsHamcrest.SimpleMatcher;
/**
* The actual value is a function and, when invoked, it should throw an exception with the given name.
*
* @param exceptionName Name of the expected exception
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function raises(exceptionName: string): JsHamcrest.SimpleMatcher;
/**
* The actual value is a function and, when invoked, it should raise any exception.
*
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function raisesAnything(): JsHamcrest.SimpleMatcher;
/**
* The actual value must be the same as expected.
*
* @param expected Expected value
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function sameAs(expected: any): JsHamcrest.SimpleMatcher;
/**
* Matches any truthy value (not undefined, null, false, 0, NaN, or "").
*
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function truth(): JsHamcrest.SimpleMatcher;
//
// Number Matchers
//
/**
* The actual number must be between the given range (inclusive).
*
* @param start Range start
* @return {JsHamcrest.BetweenBuilder} Builder object with an and(end) method, which returns a JsHamcrest.SimpleMatcher instance and thus should be called to finish the matcher creation
*/
export function between(start: any): JsHamcrest.BetweenBuilder;
/**
* The actual number must be close enough to expected, that is, the actual number is equal to a value within some range of acceptable error.
*
* @param expected Expected number
* @param [delta=0] Expected difference delta
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function closeTo(expected: number, delta?: number): JsHamcrest.SimpleMatcher;
/**
* The actual number must be divisible by divisor.
*
* @param divisor Divisor
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function divisibleBy(divisor: number): JsHamcrest.SimpleMatcher;
/**
* The actual number must be even.
*
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function even(): JsHamcrest.SimpleMatcher;
/**
* The actual number must be greater than expected.
*
* @param expected Expected number
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function greaterThan(expected: any): JsHamcrest.SimpleMatcher;
/**
* The actual number must be greater than or equal to expected.
*
* @param expected Expected number
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function greaterThanOrEqualTo(expected: any): JsHamcrest.SimpleMatcher;
/**
* The actual number must be less than expected.
*
* @param expected Expected number
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function lessThan(expected: any): JsHamcrest.SimpleMatcher;
/**
* The actual number must be less than or equal to expected.
*
* @param expected Expected number
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function lessThanOrEqualTo(expected: any): JsHamcrest.SimpleMatcher;
/**
* The actual value must not be a number.
*
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function notANumber(): JsHamcrest.SimpleMatcher;
/**
* The actual number must be odd.
*
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function odd(): JsHamcrest.SimpleMatcher;
/**
* The actual number must be zero.
*
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function zero(): JsHamcrest.SimpleMatcher;
//
// Object Matchers
//
/**
* The actual value must be a boolean.
*
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function bool(): JsHamcrest.SimpleMatcher;
/**
* The actual value must be a function.
*
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function func(): JsHamcrest.SimpleMatcher;
/**
* The actual value has a function with the given name.
*
* @param functionName Function name
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function hasFunction(functionName: string): JsHamcrest.SimpleMatcher;
/**
* The actual value has an attribute with the given name.
*
* @param memberName Member name
* @param [matcherOrValue] Instance of JsHamcrest.SimpleMatcher or a value
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function hasMember(memberName: string, matcherOrValue?: any): JsHamcrest.SimpleMatcher;
/**
* The actual value must be an instance of clazz.
*
* @param clazz Constructor function
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function instanceOf(clazz: new() => any): JsHamcrest.SimpleMatcher;
/**
* The actual value must be a number.
*
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function number(): JsHamcrest.SimpleMatcher;
/**
* The actual value must be an object.
*
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function object(): JsHamcrest.SimpleMatcher;
/**
* The actual value must be a string.
*
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function string(): JsHamcrest.SimpleMatcher;
/**
* The actual value must be of the given type.
*
* @param typeName Name of the type
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function typeOf(typeName: string): JsHamcrest.SimpleMatcher;
//
// Text Matchers
//
/**
* The actual string must have a substring equals to str.
*
* @param str Substring
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function containsString(str: string): JsHamcrest.SimpleMatcher;
/**
* The actual string must look like an e-mail address.
*
* Warning: This matcher is not fully compliant with RFC2822 due to its complexity.
*
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function emailAddress(): JsHamcrest.SimpleMatcher;
/**
* The actual string must end with str.
*
* @param str Substring
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function endsWith(str: string): JsHamcrest.SimpleMatcher;
/**
* The actual string must be equal to str, ignoring case.
*
* @param str String
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function equalIgnoringCase(str: string): JsHamcrest.SimpleMatcher;
/**
* The actual string must match regex.
*
* @param regex String
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function matches(regex: RegExp): JsHamcrest.SimpleMatcher;
/**
* The actual string must start with str.
*
* @param str Substring
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
export function startsWith(str: string): JsHamcrest.SimpleMatcher;
}
/**
* Provides methods for exposing matchers and operators for several testing frameworks.
*/
module Integration {
/**
* Copies all members of the Matchers and Operators modules to target.
*
* Does not overwrite properties with the same name.
*
* @param target
*/
export function copyMembers(target: {}): void;
/**
* Copies all members of source to target.
*
* Does not overwrite properties with the same name.
*
* @param source
* @param target
*/
export function copyMembers(source: {}, target: {}): void;
/**
* Adds the members of the given object to JsHamcrest.Matchers namespace.
*
* @param source
*/
export function installMatchers(source: {}): void;
/**
* Adds the members of the given object to JsHamcrest.Operators namespace.
*
* @param source
*/
export function installOperators(source: {}): void;
//
// Testing Frameworks
//
/**
* Uses the web browser's alert() function to display the assertion results.
* Great for quick prototyping.
*/
export function WebBrowser(): void;
/**
* Uses Rhino's print() function to display the assertion results.
* Great for quick prototyping.
*/
export function Rhino(): void;
/**
* JsTestDriver integration.
*
* @param params Omit to copy members to global scope
*/
export function JsTestDriver(params?: { scope?: {} }): void;
/**
* NodeUnit (Node.js Unit Testing) integration.
*
* @param params Omit to copy members to "global"
*/
export function Nodeunit(params?: { scope?: {} }): void;
/**
* JsUnitTest integration.
*
* @param params Omit to copy members to "JsUnitTest.Unit.Testcase.prototype"
*/
export function JsUnitTest(params?: { scope?: {} }): void;
/**
* YUITest (Yahoo UI) integration.
*
* @param params Omit to copy members to global scope
*/
export function YUITest(params?: { scope?: {} }): void;
/**
* QUnit (JQuery) integration.
*
* @param params Omit to copy members to global scope
*/
export function QUnit(params?: { scope?: {} }): void;
/**
* jsUnity integration.
*
* @param params Omit to copy members to "jsUnity.env.defaultScope"
*/
export function jsUnity(params?: { scope?: {}; attachAssertions?: boolean }): void;
/**
* Screw.Unit integration.
*
* @param params Omit to copy members to "Screw.Matchers"
*/
export function screwunit(params?: { scope?: {} }): void;
/**
* Jasmine integration.
*
* @param params Omit to copy members to global scope
*/
export function jasmine(params?: { scope?: {} }): void;
}
//
// Builders
//
/**
* Used by the between() matcher to specify the ending value.
*/
export class BetweenBuilder {
and(end: any): SimpleMatcher;
}
}
//
// Functions that are copied by copyMembers() to the global scope are copy-n-pasted here.
//
// TODO There must be a better way to do this, and not every testing framework places them in the global scope.
//
//
// Assert
//
/**
* Fails if the actual value does not match the matcher.
*
* @param actual Value to test against the matcher
* @param matcher Applied to the value
* @param message Prepends the built description
* @return {JsHamcrest.Description} Contains the message, actual value, matcher, and result
*/
declare function assertThat(actual: any, matcher?: JsHamcrest.Matcher, message?: any): JsHamcrest.Description;
//
// Collection Matchers
//
/**
* The length of the actual value must be zero.
*
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
declare function empty(): JsHamcrest.SimpleMatcher;
/**
* The actual value should be an array and matcherOrValue must match all items.
*
* @param matcherOrValue Instance of JsHamcrest.SimpleMatcher or a value
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
declare function everyItem(matcherOrValue: any): JsHamcrest.SimpleMatcher;
/**
* The actual value should be an array and it must contain at least one value that matches matcherOrValue.
*
* @param matcherOrValue Instance of JsHamcrest.SimpleMatcher or a value
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
declare function hasItem(matcherOrValue: any): JsHamcrest.SimpleMatcher;
/**
* The actual value should be an array and matchersOrValues must match at least one item.
*
* @param matchersOrValues Instances of JsHamcrest.SimpleMatcher and/or values
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
declare function hasItems(...matchersOrValues: any[]): JsHamcrest.SimpleMatcher;
/**
* The length of the actual value must match matcherOrValue.
*
* @param matcherOrValue Instance of JsHamcrest.SimpleMatcher or a value
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
declare function hasSize(matcherOrValue: any): JsHamcrest.SimpleMatcher;
/**
* The given array or arguments must contain the actual value.
*
* @param items Array or list of values
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
declare function isIn(...items: any[]): JsHamcrest.SimpleMatcher;
/**
* Alias to isIn() function.
*
* @param items Array or list of values
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
declare function oneOf(...items: any[]): JsHamcrest.SimpleMatcher;
//
// Core Matchers
//
/**
* All matchesOrValues must match the actual value. This matcher behaves pretty much like the JavaScript && (and) operator.
*
* @param matchersOrValues Instances of JsHamcrest.SimpleMatcher and/or values
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
declare function allOf(...matchersOrValues: any[]): JsHamcrest.SimpleMatcher;
/**
* At least one of the matchersOrValues should match the actual value. This matcher behaves pretty much like the JavaScript || (or) operator.
*
* @param matchersOrValues Instances of JsHamcrest.SimpleMatcher and/or values
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
declare function anyOf(...matchersOrValues: any[]): JsHamcrest.SimpleMatcher;
/**
* Useless always-match matcher.
*
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
declare function anything(): JsHamcrest.SimpleMatcher;
/**
* Combinable matcher where the actual value must match all the given matchers or values.
*
* @param matcherOrValue Instance of JsHamcrest.SimpleMatcher or a value
* @return {JsHamcrest.CombinableMatcher} Instance of JsHamcrest.CombinableMatcher
*/
declare function both(matcherOrValue: any): JsHamcrest.CombinableMatcher;
/**
* Combinable matcher where the actual value must match at least one of the given matchers or values.
*
* @param matcherOrValue Instance of JsHamcrest.SimpleMatcher or a value
* @return {JsHamcrest.CombinableMatcher} Instance of JsHamcrest.CombinableMatcher
*/
declare function either(matcherOrValue: any): JsHamcrest.CombinableMatcher;
/**
* The actual value must be equal to expected.
*
* @param expected Expected value
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
declare function equalTo(expected: any): JsHamcrest.SimpleMatcher;
/**
* Delegate-only matcher frequently used to improve readability.
*
* @param matcherOrValue Instance of JsHamcrest.SimpleMatcher or a value
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
declare function is(matcherOrValue: any): JsHamcrest.SimpleMatcher;
/**
* The actual value must be null or undefined.
*
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
declare function nil(): JsHamcrest.SimpleMatcher;
/**
* The actual value must not match matcherOrValue.
*
* @param matcherOrValue Instance of JsHamcrest.SimpleMatcher or a value
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
declare function not(matcherOrValue: any): JsHamcrest.SimpleMatcher;
/**
* The actual value is a function and, when invoked, it should throw an exception with the given name.
*
* @param exceptionName Name of the expected exception
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
declare function raises(exceptionName: string): JsHamcrest.SimpleMatcher;
/**
* The actual value is a function and, when invoked, it should raise any exception.
*
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
declare function raisesAnything(): JsHamcrest.SimpleMatcher;
/**
* The actual value must be the same as expected.
*
* @param expected Expected value
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
declare function sameAs(expected: any): JsHamcrest.SimpleMatcher;
/**
* Matches any truthy value (not undefined, null, false, 0, NaN, or "").
*
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
declare function truth(): JsHamcrest.SimpleMatcher;
//
// Number Matchers
//
/**
* The actual number must be between the given range (inclusive).
*
* @param start Range start
* @return {JsHamcrest.BetweenBuilder} Builder object with an and(end) method, which returns a JsHamcrest.SimpleMatcher instance and thus should be called to finish the matcher creation
*/
declare function between(start: any): JsHamcrest.BetweenBuilder;
/**
* The actual number must be close enough to expected, that is, the actual number is equal to a value within some range of acceptable error.
*
* @param expected Expected number
* @param [delta=0] Expected difference delta
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
declare function closeTo(expected: number, delta?: number): JsHamcrest.SimpleMatcher;
/**
* The actual number must be divisible by divisor.
*
* @param divisor Divisor
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
declare function divisibleBy(divisor: number): JsHamcrest.SimpleMatcher;
/**
* The actual number must be even.
*
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
declare function even(): JsHamcrest.SimpleMatcher;
/**
* The actual number must be greater than expected.
*
* @param expected Expected number
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
declare function greaterThan(expected: any): JsHamcrest.SimpleMatcher;
/**
* The actual number must be greater than or equal to expected.
*
* @param expected Expected number
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
declare function greaterThanOrEqualTo(expected: any): JsHamcrest.SimpleMatcher;
/**
* The actual number must be less than expected.
*
* @param expected Expected number
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
declare function lessThan(expected: any): JsHamcrest.SimpleMatcher;
/**
* The actual number must be less than or equal to expected.
*
* @param expected Expected number
* @return {JsHamcrest.SimpleMatcher} Instance of JsHamcrest.SimpleMatcher
*/
declare function lessThanOrEqualTo(expected: any): JsHamcrest.SimpleMatcher;
/**
* The actual value must not be a number.
*