react-grid-layout 0.18.2 → 0.18.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1182 @@
1
+ // flow-typed signature: 27f8467378a99b6130bd20f54f31a644
2
+ // flow-typed version: 6cb9e99836/jest_v24.x.x/flow_>=v0.104.x
3
+
4
+ type JestMockFn<TArguments: $ReadOnlyArray<*>, TReturn> = {
5
+ (...args: TArguments): TReturn,
6
+ /**
7
+ * An object for introspecting mock calls
8
+ */
9
+ mock: {
10
+ /**
11
+ * An array that represents all calls that have been made into this mock
12
+ * function. Each call is represented by an array of arguments that were
13
+ * passed during the call.
14
+ */
15
+ calls: Array<TArguments>,
16
+ /**
17
+ * An array that contains all the object instances that have been
18
+ * instantiated from this mock function.
19
+ */
20
+ instances: Array<TReturn>,
21
+ /**
22
+ * An array that contains all the object results that have been
23
+ * returned by this mock function call
24
+ */
25
+ results: Array<{
26
+ isThrow: boolean,
27
+ value: TReturn,
28
+ ...
29
+ }>,
30
+ ...
31
+ },
32
+ /**
33
+ * Resets all information stored in the mockFn.mock.calls and
34
+ * mockFn.mock.instances arrays. Often this is useful when you want to clean
35
+ * up a mock's usage data between two assertions.
36
+ */
37
+ mockClear(): void,
38
+ /**
39
+ * Resets all information stored in the mock. This is useful when you want to
40
+ * completely restore a mock back to its initial state.
41
+ */
42
+ mockReset(): void,
43
+ /**
44
+ * Removes the mock and restores the initial implementation. This is useful
45
+ * when you want to mock functions in certain test cases and restore the
46
+ * original implementation in others. Beware that mockFn.mockRestore only
47
+ * works when mock was created with jest.spyOn. Thus you have to take care of
48
+ * restoration yourself when manually assigning jest.fn().
49
+ */
50
+ mockRestore(): void,
51
+ /**
52
+ * Accepts a function that should be used as the implementation of the mock.
53
+ * The mock itself will still record all calls that go into and instances
54
+ * that come from itself -- the only difference is that the implementation
55
+ * will also be executed when the mock is called.
56
+ */
57
+ mockImplementation(
58
+ fn: (...args: TArguments) => TReturn
59
+ ): JestMockFn<TArguments, TReturn>,
60
+ /**
61
+ * Accepts a function that will be used as an implementation of the mock for
62
+ * one call to the mocked function. Can be chained so that multiple function
63
+ * calls produce different results.
64
+ */
65
+ mockImplementationOnce(
66
+ fn: (...args: TArguments) => TReturn
67
+ ): JestMockFn<TArguments, TReturn>,
68
+ /**
69
+ * Accepts a string to use in test result output in place of "jest.fn()" to
70
+ * indicate which mock function is being referenced.
71
+ */
72
+ mockName(name: string): JestMockFn<TArguments, TReturn>,
73
+ /**
74
+ * Just a simple sugar function for returning `this`
75
+ */
76
+ mockReturnThis(): void,
77
+ /**
78
+ * Accepts a value that will be returned whenever the mock function is called.
79
+ */
80
+ mockReturnValue(value: TReturn): JestMockFn<TArguments, TReturn>,
81
+ /**
82
+ * Sugar for only returning a value once inside your mock
83
+ */
84
+ mockReturnValueOnce(value: TReturn): JestMockFn<TArguments, TReturn>,
85
+ /**
86
+ * Sugar for jest.fn().mockImplementation(() => Promise.resolve(value))
87
+ */
88
+ mockResolvedValue(value: TReturn): JestMockFn<TArguments, Promise<TReturn>>,
89
+ /**
90
+ * Sugar for jest.fn().mockImplementationOnce(() => Promise.resolve(value))
91
+ */
92
+ mockResolvedValueOnce(
93
+ value: TReturn
94
+ ): JestMockFn<TArguments, Promise<TReturn>>,
95
+ /**
96
+ * Sugar for jest.fn().mockImplementation(() => Promise.reject(value))
97
+ */
98
+ mockRejectedValue(value: TReturn): JestMockFn<TArguments, Promise<any>>,
99
+ /**
100
+ * Sugar for jest.fn().mockImplementationOnce(() => Promise.reject(value))
101
+ */
102
+ mockRejectedValueOnce(value: TReturn): JestMockFn<TArguments, Promise<any>>,
103
+ ...
104
+ };
105
+
106
+ type JestAsymmetricEqualityType = { /**
107
+ * A custom Jasmine equality tester
108
+ */
109
+ asymmetricMatch(value: mixed): boolean, ... };
110
+
111
+ type JestCallsType = {
112
+ allArgs(): mixed,
113
+ all(): mixed,
114
+ any(): boolean,
115
+ count(): number,
116
+ first(): mixed,
117
+ mostRecent(): mixed,
118
+ reset(): void,
119
+ ...
120
+ };
121
+
122
+ type JestClockType = {
123
+ install(): void,
124
+ mockDate(date: Date): void,
125
+ tick(milliseconds?: number): void,
126
+ uninstall(): void,
127
+ ...
128
+ };
129
+
130
+ type JestMatcherResult = {
131
+ message?: string | (() => string),
132
+ pass: boolean,
133
+ ...
134
+ };
135
+
136
+ type JestMatcher = (
137
+ received: any,
138
+ ...actual: Array<any>
139
+ ) => JestMatcherResult | Promise<JestMatcherResult>;
140
+
141
+ type JestPromiseType = {
142
+ /**
143
+ * Use rejects to unwrap the reason of a rejected promise so any other
144
+ * matcher can be chained. If the promise is fulfilled the assertion fails.
145
+ */
146
+ rejects: JestExpectType,
147
+ /**
148
+ * Use resolves to unwrap the value of a fulfilled promise so any other
149
+ * matcher can be chained. If the promise is rejected the assertion fails.
150
+ */
151
+ resolves: JestExpectType,
152
+ ...
153
+ };
154
+
155
+ /**
156
+ * Jest allows functions and classes to be used as test names in test() and
157
+ * describe()
158
+ */
159
+ type JestTestName = string | Function;
160
+
161
+ /**
162
+ * Plugin: jest-styled-components
163
+ */
164
+
165
+ type JestStyledComponentsMatcherValue =
166
+ | string
167
+ | JestAsymmetricEqualityType
168
+ | RegExp
169
+ | typeof undefined;
170
+
171
+ type JestStyledComponentsMatcherOptions = {
172
+ media?: string,
173
+ modifier?: string,
174
+ supports?: string,
175
+ ...
176
+ };
177
+
178
+ type JestStyledComponentsMatchersType = { toHaveStyleRule(
179
+ property: string,
180
+ value: JestStyledComponentsMatcherValue,
181
+ options?: JestStyledComponentsMatcherOptions
182
+ ): void, ... };
183
+
184
+ /**
185
+ * Plugin: jest-enzyme
186
+ */
187
+ type EnzymeMatchersType = {
188
+ // 5.x
189
+ toBeEmpty(): void,
190
+ toBePresent(): void,
191
+ // 6.x
192
+ toBeChecked(): void,
193
+ toBeDisabled(): void,
194
+ toBeEmptyRender(): void,
195
+ toContainMatchingElement(selector: string): void,
196
+ toContainMatchingElements(n: number, selector: string): void,
197
+ toContainExactlyOneMatchingElement(selector: string): void,
198
+ toContainReact(element: React$Element<any>): void,
199
+ toExist(): void,
200
+ toHaveClassName(className: string): void,
201
+ toHaveHTML(html: string): void,
202
+ toHaveProp: ((propKey: string, propValue?: any) => void) &
203
+ ((props: {...}) => void),
204
+ toHaveRef(refName: string): void,
205
+ toHaveState: ((stateKey: string, stateValue?: any) => void) &
206
+ ((state: {...}) => void),
207
+ toHaveStyle: ((styleKey: string, styleValue?: any) => void) &
208
+ ((style: {...}) => void),
209
+ toHaveTagName(tagName: string): void,
210
+ toHaveText(text: string): void,
211
+ toHaveValue(value: any): void,
212
+ toIncludeText(text: string): void,
213
+ toMatchElement(
214
+ element: React$Element<any>,
215
+ options?: {| ignoreProps?: boolean, verbose?: boolean |}
216
+ ): void,
217
+ toMatchSelector(selector: string): void,
218
+ // 7.x
219
+ toHaveDisplayName(name: string): void,
220
+ ...
221
+ };
222
+
223
+ // DOM testing library extensions (jest-dom)
224
+ // https://github.com/testing-library/jest-dom
225
+ type DomTestingLibraryType = {
226
+ /**
227
+ * @deprecated
228
+ */
229
+ toBeInTheDOM(container?: HTMLElement): void,
230
+ toBeInTheDocument(): void,
231
+ toBeVisible(): void,
232
+ toBeEmpty(): void,
233
+ toBeDisabled(): void,
234
+ toBeEnabled(): void,
235
+ toBeInvalid(): void,
236
+ toBeRequired(): void,
237
+ toBeValid(): void,
238
+ toContainElement(element: HTMLElement | null): void,
239
+ toContainHTML(htmlText: string): void,
240
+ toHaveAttribute(attr: string, value?: any): void,
241
+ toHaveClass(...classNames: string[]): void,
242
+ toHaveFocus(): void,
243
+ toHaveFormValues(expectedValues: { [name: string]: any, ... }): void,
244
+ toHaveStyle(css: string): void,
245
+ toHaveTextContent(
246
+ text: string | RegExp,
247
+ options?: { normalizeWhitespace: boolean, ... }
248
+ ): void,
249
+ toHaveValue(value?: string | string[] | number): void,
250
+ ...
251
+ };
252
+
253
+ // Jest JQuery Matchers: https://github.com/unindented/custom-jquery-matchers
254
+ type JestJQueryMatchersType = {
255
+ toExist(): void,
256
+ toHaveLength(len: number): void,
257
+ toHaveId(id: string): void,
258
+ toHaveClass(className: string): void,
259
+ toHaveTag(tag: string): void,
260
+ toHaveAttr(key: string, val?: any): void,
261
+ toHaveProp(key: string, val?: any): void,
262
+ toHaveText(text: string | RegExp): void,
263
+ toHaveData(key: string, val?: any): void,
264
+ toHaveValue(val: any): void,
265
+ toHaveCss(css: { [key: string]: any, ... }): void,
266
+ toBeChecked(): void,
267
+ toBeDisabled(): void,
268
+ toBeEmpty(): void,
269
+ toBeHidden(): void,
270
+ toBeSelected(): void,
271
+ toBeVisible(): void,
272
+ toBeFocused(): void,
273
+ toBeInDom(): void,
274
+ toBeMatchedBy(sel: string): void,
275
+ toHaveDescendant(sel: string): void,
276
+ toHaveDescendantWithText(sel: string, text: string | RegExp): void,
277
+ ...
278
+ };
279
+
280
+ // Jest Extended Matchers: https://github.com/jest-community/jest-extended
281
+ type JestExtendedMatchersType = {
282
+ /**
283
+ * Note: Currently unimplemented
284
+ * Passing assertion
285
+ *
286
+ * @param {String} message
287
+ */
288
+ // pass(message: string): void;
289
+
290
+ /**
291
+ * Note: Currently unimplemented
292
+ * Failing assertion
293
+ *
294
+ * @param {String} message
295
+ */
296
+ // fail(message: string): void;
297
+
298
+ /**
299
+ * Use .toBeEmpty when checking if a String '', Array [] or Object {} is empty.
300
+ */
301
+ toBeEmpty(): void,
302
+ /**
303
+ * Use .toBeOneOf when checking if a value is a member of a given Array.
304
+ * @param {Array.<*>} members
305
+ */
306
+ toBeOneOf(members: any[]): void,
307
+ /**
308
+ * Use `.toBeNil` when checking a value is `null` or `undefined`.
309
+ */
310
+ toBeNil(): void,
311
+ /**
312
+ * Use `.toSatisfy` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean`.
313
+ * @param {Function} predicate
314
+ */
315
+ toSatisfy(predicate: (n: any) => boolean): void,
316
+ /**
317
+ * Use `.toBeArray` when checking if a value is an `Array`.
318
+ */
319
+ toBeArray(): void,
320
+ /**
321
+ * Use `.toBeArrayOfSize` when checking if a value is an `Array` of size x.
322
+ * @param {Number} x
323
+ */
324
+ toBeArrayOfSize(x: number): void,
325
+ /**
326
+ * Use `.toIncludeAllMembers` when checking if an `Array` contains all of the same members of a given set.
327
+ * @param {Array.<*>} members
328
+ */
329
+ toIncludeAllMembers(members: any[]): void,
330
+ /**
331
+ * Use `.toIncludeAnyMembers` when checking if an `Array` contains any of the members of a given set.
332
+ * @param {Array.<*>} members
333
+ */
334
+ toIncludeAnyMembers(members: any[]): void,
335
+ /**
336
+ * Use `.toSatisfyAll` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean` for all values in an array.
337
+ * @param {Function} predicate
338
+ */
339
+ toSatisfyAll(predicate: (n: any) => boolean): void,
340
+ /**
341
+ * Use `.toBeBoolean` when checking if a value is a `Boolean`.
342
+ */
343
+ toBeBoolean(): void,
344
+ /**
345
+ * Use `.toBeTrue` when checking a value is equal (===) to `true`.
346
+ */
347
+ toBeTrue(): void,
348
+ /**
349
+ * Use `.toBeFalse` when checking a value is equal (===) to `false`.
350
+ */
351
+ toBeFalse(): void,
352
+ /**
353
+ * Use .toBeDate when checking if a value is a Date.
354
+ */
355
+ toBeDate(): void,
356
+ /**
357
+ * Use `.toBeFunction` when checking if a value is a `Function`.
358
+ */
359
+ toBeFunction(): void,
360
+ /**
361
+ * Use `.toHaveBeenCalledBefore` when checking if a `Mock` was called before another `Mock`.
362
+ *
363
+ * Note: Required Jest version >22
364
+ * Note: Your mock functions will have to be asynchronous to cause the timestamps inside of Jest to occur in a differentJS event loop, otherwise the mock timestamps will all be the same
365
+ *
366
+ * @param {Mock} mock
367
+ */
368
+ toHaveBeenCalledBefore(mock: JestMockFn<any, any>): void,
369
+ /**
370
+ * Use `.toBeNumber` when checking if a value is a `Number`.
371
+ */
372
+ toBeNumber(): void,
373
+ /**
374
+ * Use `.toBeNaN` when checking a value is `NaN`.
375
+ */
376
+ toBeNaN(): void,
377
+ /**
378
+ * Use `.toBeFinite` when checking if a value is a `Number`, not `NaN` or `Infinity`.
379
+ */
380
+ toBeFinite(): void,
381
+ /**
382
+ * Use `.toBePositive` when checking if a value is a positive `Number`.
383
+ */
384
+ toBePositive(): void,
385
+ /**
386
+ * Use `.toBeNegative` when checking if a value is a negative `Number`.
387
+ */
388
+ toBeNegative(): void,
389
+ /**
390
+ * Use `.toBeEven` when checking if a value is an even `Number`.
391
+ */
392
+ toBeEven(): void,
393
+ /**
394
+ * Use `.toBeOdd` when checking if a value is an odd `Number`.
395
+ */
396
+ toBeOdd(): void,
397
+ /**
398
+ * Use `.toBeWithin` when checking if a number is in between the given bounds of: start (inclusive) and end (exclusive).
399
+ *
400
+ * @param {Number} start
401
+ * @param {Number} end
402
+ */
403
+ toBeWithin(start: number, end: number): void,
404
+ /**
405
+ * Use `.toBeObject` when checking if a value is an `Object`.
406
+ */
407
+ toBeObject(): void,
408
+ /**
409
+ * Use `.toContainKey` when checking if an object contains the provided key.
410
+ *
411
+ * @param {String} key
412
+ */
413
+ toContainKey(key: string): void,
414
+ /**
415
+ * Use `.toContainKeys` when checking if an object has all of the provided keys.
416
+ *
417
+ * @param {Array.<String>} keys
418
+ */
419
+ toContainKeys(keys: string[]): void,
420
+ /**
421
+ * Use `.toContainAllKeys` when checking if an object only contains all of the provided keys.
422
+ *
423
+ * @param {Array.<String>} keys
424
+ */
425
+ toContainAllKeys(keys: string[]): void,
426
+ /**
427
+ * Use `.toContainAnyKeys` when checking if an object contains at least one of the provided keys.
428
+ *
429
+ * @param {Array.<String>} keys
430
+ */
431
+ toContainAnyKeys(keys: string[]): void,
432
+ /**
433
+ * Use `.toContainValue` when checking if an object contains the provided value.
434
+ *
435
+ * @param {*} value
436
+ */
437
+ toContainValue(value: any): void,
438
+ /**
439
+ * Use `.toContainValues` when checking if an object contains all of the provided values.
440
+ *
441
+ * @param {Array.<*>} values
442
+ */
443
+ toContainValues(values: any[]): void,
444
+ /**
445
+ * Use `.toContainAllValues` when checking if an object only contains all of the provided values.
446
+ *
447
+ * @param {Array.<*>} values
448
+ */
449
+ toContainAllValues(values: any[]): void,
450
+ /**
451
+ * Use `.toContainAnyValues` when checking if an object contains at least one of the provided values.
452
+ *
453
+ * @param {Array.<*>} values
454
+ */
455
+ toContainAnyValues(values: any[]): void,
456
+ /**
457
+ * Use `.toContainEntry` when checking if an object contains the provided entry.
458
+ *
459
+ * @param {Array.<String, String>} entry
460
+ */
461
+ toContainEntry(entry: [string, string]): void,
462
+ /**
463
+ * Use `.toContainEntries` when checking if an object contains all of the provided entries.
464
+ *
465
+ * @param {Array.<Array.<String, String>>} entries
466
+ */
467
+ toContainEntries(entries: [string, string][]): void,
468
+ /**
469
+ * Use `.toContainAllEntries` when checking if an object only contains all of the provided entries.
470
+ *
471
+ * @param {Array.<Array.<String, String>>} entries
472
+ */
473
+ toContainAllEntries(entries: [string, string][]): void,
474
+ /**
475
+ * Use `.toContainAnyEntries` when checking if an object contains at least one of the provided entries.
476
+ *
477
+ * @param {Array.<Array.<String, String>>} entries
478
+ */
479
+ toContainAnyEntries(entries: [string, string][]): void,
480
+ /**
481
+ * Use `.toBeExtensible` when checking if an object is extensible.
482
+ */
483
+ toBeExtensible(): void,
484
+ /**
485
+ * Use `.toBeFrozen` when checking if an object is frozen.
486
+ */
487
+ toBeFrozen(): void,
488
+ /**
489
+ * Use `.toBeSealed` when checking if an object is sealed.
490
+ */
491
+ toBeSealed(): void,
492
+ /**
493
+ * Use `.toBeString` when checking if a value is a `String`.
494
+ */
495
+ toBeString(): void,
496
+ /**
497
+ * Use `.toEqualCaseInsensitive` when checking if a string is equal (===) to another ignoring the casing of both strings.
498
+ *
499
+ * @param {String} string
500
+ */
501
+ toEqualCaseInsensitive(string: string): void,
502
+ /**
503
+ * Use `.toStartWith` when checking if a `String` starts with a given `String` prefix.
504
+ *
505
+ * @param {String} prefix
506
+ */
507
+ toStartWith(prefix: string): void,
508
+ /**
509
+ * Use `.toEndWith` when checking if a `String` ends with a given `String` suffix.
510
+ *
511
+ * @param {String} suffix
512
+ */
513
+ toEndWith(suffix: string): void,
514
+ /**
515
+ * Use `.toInclude` when checking if a `String` includes the given `String` substring.
516
+ *
517
+ * @param {String} substring
518
+ */
519
+ toInclude(substring: string): void,
520
+ /**
521
+ * Use `.toIncludeRepeated` when checking if a `String` includes the given `String` substring the correct number of times.
522
+ *
523
+ * @param {String} substring
524
+ * @param {Number} times
525
+ */
526
+ toIncludeRepeated(substring: string, times: number): void,
527
+ /**
528
+ * Use `.toIncludeMultiple` when checking if a `String` includes all of the given substrings.
529
+ *
530
+ * @param {Array.<String>} substring
531
+ */
532
+ toIncludeMultiple(substring: string[]): void,
533
+ ...
534
+ };
535
+
536
+ interface JestExpectType {
537
+ not: JestExpectType &
538
+ EnzymeMatchersType &
539
+ DomTestingLibraryType &
540
+ JestJQueryMatchersType &
541
+ JestStyledComponentsMatchersType &
542
+ JestExtendedMatchersType;
543
+ /**
544
+ * If you have a mock function, you can use .lastCalledWith to test what
545
+ * arguments it was last called with.
546
+ */
547
+ lastCalledWith(...args: Array<any>): void;
548
+ /**
549
+ * toBe just checks that a value is what you expect. It uses === to check
550
+ * strict equality.
551
+ */
552
+ toBe(value: any): void;
553
+ /**
554
+ * Use .toBeCalledWith to ensure that a mock function was called with
555
+ * specific arguments.
556
+ */
557
+ toBeCalledWith(...args: Array<any>): void;
558
+ /**
559
+ * Using exact equality with floating point numbers is a bad idea. Rounding
560
+ * means that intuitive things fail.
561
+ */
562
+ toBeCloseTo(num: number, delta: any): void;
563
+ /**
564
+ * Use .toBeDefined to check that a variable is not undefined.
565
+ */
566
+ toBeDefined(): void;
567
+ /**
568
+ * Use .toBeFalsy when you don't care what a value is, you just want to
569
+ * ensure a value is false in a boolean context.
570
+ */
571
+ toBeFalsy(): void;
572
+ /**
573
+ * To compare floating point numbers, you can use toBeGreaterThan.
574
+ */
575
+ toBeGreaterThan(number: number): void;
576
+ /**
577
+ * To compare floating point numbers, you can use toBeGreaterThanOrEqual.
578
+ */
579
+ toBeGreaterThanOrEqual(number: number): void;
580
+ /**
581
+ * To compare floating point numbers, you can use toBeLessThan.
582
+ */
583
+ toBeLessThan(number: number): void;
584
+ /**
585
+ * To compare floating point numbers, you can use toBeLessThanOrEqual.
586
+ */
587
+ toBeLessThanOrEqual(number: number): void;
588
+ /**
589
+ * Use .toBeInstanceOf(Class) to check that an object is an instance of a
590
+ * class.
591
+ */
592
+ toBeInstanceOf(cls: Class<*>): void;
593
+ /**
594
+ * .toBeNull() is the same as .toBe(null) but the error messages are a bit
595
+ * nicer.
596
+ */
597
+ toBeNull(): void;
598
+ /**
599
+ * Use .toBeTruthy when you don't care what a value is, you just want to
600
+ * ensure a value is true in a boolean context.
601
+ */
602
+ toBeTruthy(): void;
603
+ /**
604
+ * Use .toBeUndefined to check that a variable is undefined.
605
+ */
606
+ toBeUndefined(): void;
607
+ /**
608
+ * Use .toContain when you want to check that an item is in a list. For
609
+ * testing the items in the list, this uses ===, a strict equality check.
610
+ */
611
+ toContain(item: any): void;
612
+ /**
613
+ * Use .toContainEqual when you want to check that an item is in a list. For
614
+ * testing the items in the list, this matcher recursively checks the
615
+ * equality of all fields, rather than checking for object identity.
616
+ */
617
+ toContainEqual(item: any): void;
618
+ /**
619
+ * Use .toEqual when you want to check that two objects have the same value.
620
+ * This matcher recursively checks the equality of all fields, rather than
621
+ * checking for object identity.
622
+ */
623
+ toEqual(value: any): void;
624
+ /**
625
+ * Use .toHaveBeenCalled to ensure that a mock function got called.
626
+ */
627
+ toHaveBeenCalled(): void;
628
+ toBeCalled(): void;
629
+ /**
630
+ * Use .toHaveBeenCalledTimes to ensure that a mock function got called exact
631
+ * number of times.
632
+ */
633
+ toHaveBeenCalledTimes(number: number): void;
634
+ toBeCalledTimes(number: number): void;
635
+ /**
636
+ *
637
+ */
638
+ toHaveBeenNthCalledWith(nthCall: number, ...args: Array<any>): void;
639
+ nthCalledWith(nthCall: number, ...args: Array<any>): void;
640
+ /**
641
+ *
642
+ */
643
+ toHaveReturned(): void;
644
+ toReturn(): void;
645
+ /**
646
+ *
647
+ */
648
+ toHaveReturnedTimes(number: number): void;
649
+ toReturnTimes(number: number): void;
650
+ /**
651
+ *
652
+ */
653
+ toHaveReturnedWith(value: any): void;
654
+ toReturnWith(value: any): void;
655
+ /**
656
+ *
657
+ */
658
+ toHaveLastReturnedWith(value: any): void;
659
+ lastReturnedWith(value: any): void;
660
+ /**
661
+ *
662
+ */
663
+ toHaveNthReturnedWith(nthCall: number, value: any): void;
664
+ nthReturnedWith(nthCall: number, value: any): void;
665
+ /**
666
+ * Use .toHaveBeenCalledWith to ensure that a mock function was called with
667
+ * specific arguments.
668
+ */
669
+ toHaveBeenCalledWith(...args: Array<any>): void;
670
+ toBeCalledWith(...args: Array<any>): void;
671
+ /**
672
+ * Use .toHaveBeenLastCalledWith to ensure that a mock function was last called
673
+ * with specific arguments.
674
+ */
675
+ toHaveBeenLastCalledWith(...args: Array<any>): void;
676
+ lastCalledWith(...args: Array<any>): void;
677
+ /**
678
+ * Check that an object has a .length property and it is set to a certain
679
+ * numeric value.
680
+ */
681
+ toHaveLength(number: number): void;
682
+ /**
683
+ *
684
+ */
685
+ toHaveProperty(propPath: string | $ReadOnlyArray<string>, value?: any): void;
686
+ /**
687
+ * Use .toMatch to check that a string matches a regular expression or string.
688
+ */
689
+ toMatch(regexpOrString: RegExp | string): void;
690
+ /**
691
+ * Use .toMatchObject to check that a javascript object matches a subset of the properties of an object.
692
+ */
693
+ toMatchObject(object: Object | Array<Object>): void;
694
+ /**
695
+ * Use .toStrictEqual to check that a javascript object matches a subset of the properties of an object.
696
+ */
697
+ toStrictEqual(value: any): void;
698
+ /**
699
+ * This ensures that an Object matches the most recent snapshot.
700
+ */
701
+ toMatchSnapshot(propertyMatchers?: any, name?: string): void;
702
+ /**
703
+ * This ensures that an Object matches the most recent snapshot.
704
+ */
705
+ toMatchSnapshot(name: string): void;
706
+
707
+ toMatchInlineSnapshot(snapshot?: string): void;
708
+ toMatchInlineSnapshot(propertyMatchers?: any, snapshot?: string): void;
709
+ /**
710
+ * Use .toThrow to test that a function throws when it is called.
711
+ * If you want to test that a specific error gets thrown, you can provide an
712
+ * argument to toThrow. The argument can be a string for the error message,
713
+ * a class for the error, or a regex that should match the error.
714
+ *
715
+ * Alias: .toThrowError
716
+ */
717
+ toThrow(message?: string | Error | Class<Error> | RegExp): void;
718
+ toThrowError(message?: string | Error | Class<Error> | RegExp): void;
719
+ /**
720
+ * Use .toThrowErrorMatchingSnapshot to test that a function throws a error
721
+ * matching the most recent snapshot when it is called.
722
+ */
723
+ toThrowErrorMatchingSnapshot(): void;
724
+ toThrowErrorMatchingInlineSnapshot(snapshot?: string): void;
725
+ }
726
+
727
+ type JestObjectType = {
728
+ /**
729
+ * Disables automatic mocking in the module loader.
730
+ *
731
+ * After this method is called, all `require()`s will return the real
732
+ * versions of each module (rather than a mocked version).
733
+ */
734
+ disableAutomock(): JestObjectType,
735
+ /**
736
+ * An un-hoisted version of disableAutomock
737
+ */
738
+ autoMockOff(): JestObjectType,
739
+ /**
740
+ * Enables automatic mocking in the module loader.
741
+ */
742
+ enableAutomock(): JestObjectType,
743
+ /**
744
+ * An un-hoisted version of enableAutomock
745
+ */
746
+ autoMockOn(): JestObjectType,
747
+ /**
748
+ * Clears the mock.calls and mock.instances properties of all mocks.
749
+ * Equivalent to calling .mockClear() on every mocked function.
750
+ */
751
+ clearAllMocks(): JestObjectType,
752
+ /**
753
+ * Resets the state of all mocks. Equivalent to calling .mockReset() on every
754
+ * mocked function.
755
+ */
756
+ resetAllMocks(): JestObjectType,
757
+ /**
758
+ * Restores all mocks back to their original value.
759
+ */
760
+ restoreAllMocks(): JestObjectType,
761
+ /**
762
+ * Removes any pending timers from the timer system.
763
+ */
764
+ clearAllTimers(): void,
765
+ /**
766
+ * Returns the number of fake timers still left to run.
767
+ */
768
+ getTimerCount(): number,
769
+ /**
770
+ * The same as `mock` but not moved to the top of the expectation by
771
+ * babel-jest.
772
+ */
773
+ doMock(moduleName: string, moduleFactory?: any): JestObjectType,
774
+ /**
775
+ * The same as `unmock` but not moved to the top of the expectation by
776
+ * babel-jest.
777
+ */
778
+ dontMock(moduleName: string): JestObjectType,
779
+ /**
780
+ * Returns a new, unused mock function. Optionally takes a mock
781
+ * implementation.
782
+ */
783
+ fn<TArguments: $ReadOnlyArray<*>, TReturn>(
784
+ implementation?: (...args: TArguments) => TReturn
785
+ ): JestMockFn<TArguments, TReturn>,
786
+ /**
787
+ * Determines if the given function is a mocked function.
788
+ */
789
+ isMockFunction(fn: Function): boolean,
790
+ /**
791
+ * Given the name of a module, use the automatic mocking system to generate a
792
+ * mocked version of the module for you.
793
+ */
794
+ genMockFromModule(moduleName: string): any,
795
+ /**
796
+ * Mocks a module with an auto-mocked version when it is being required.
797
+ *
798
+ * The second argument can be used to specify an explicit module factory that
799
+ * is being run instead of using Jest's automocking feature.
800
+ *
801
+ * The third argument can be used to create virtual mocks -- mocks of modules
802
+ * that don't exist anywhere in the system.
803
+ */
804
+ mock(
805
+ moduleName: string,
806
+ moduleFactory?: any,
807
+ options?: Object
808
+ ): JestObjectType,
809
+ /**
810
+ * Returns the actual module instead of a mock, bypassing all checks on
811
+ * whether the module should receive a mock implementation or not.
812
+ */
813
+ requireActual(moduleName: string): any,
814
+ /**
815
+ * Returns a mock module instead of the actual module, bypassing all checks
816
+ * on whether the module should be required normally or not.
817
+ */
818
+ requireMock(moduleName: string): any,
819
+ /**
820
+ * Resets the module registry - the cache of all required modules. This is
821
+ * useful to isolate modules where local state might conflict between tests.
822
+ */
823
+ resetModules(): JestObjectType,
824
+ /**
825
+ * Creates a sandbox registry for the modules that are loaded inside the
826
+ * callback function. This is useful to isolate specific modules for every
827
+ * test so that local module state doesn't conflict between tests.
828
+ */
829
+ isolateModules(fn: () => void): JestObjectType,
830
+ /**
831
+ * Exhausts the micro-task queue (usually interfaced in node via
832
+ * process.nextTick).
833
+ */
834
+ runAllTicks(): void,
835
+ /**
836
+ * Exhausts the macro-task queue (i.e., all tasks queued by setTimeout(),
837
+ * setInterval(), and setImmediate()).
838
+ */
839
+ runAllTimers(): void,
840
+ /**
841
+ * Exhausts all tasks queued by setImmediate().
842
+ */
843
+ runAllImmediates(): void,
844
+ /**
845
+ * Executes only the macro task queue (i.e. all tasks queued by setTimeout()
846
+ * or setInterval() and setImmediate()).
847
+ */
848
+ advanceTimersByTime(msToRun: number): void,
849
+ /**
850
+ * Executes only the macro task queue (i.e. all tasks queued by setTimeout()
851
+ * or setInterval() and setImmediate()).
852
+ *
853
+ * Renamed to `advanceTimersByTime`.
854
+ */
855
+ runTimersToTime(msToRun: number): void,
856
+ /**
857
+ * Executes only the macro-tasks that are currently pending (i.e., only the
858
+ * tasks that have been queued by setTimeout() or setInterval() up to this
859
+ * point)
860
+ */
861
+ runOnlyPendingTimers(): void,
862
+ /**
863
+ * Explicitly supplies the mock object that the module system should return
864
+ * for the specified module. Note: It is recommended to use jest.mock()
865
+ * instead.
866
+ */
867
+ setMock(moduleName: string, moduleExports: any): JestObjectType,
868
+ /**
869
+ * Indicates that the module system should never return a mocked version of
870
+ * the specified module from require() (e.g. that it should always return the
871
+ * real module).
872
+ */
873
+ unmock(moduleName: string): JestObjectType,
874
+ /**
875
+ * Instructs Jest to use fake versions of the standard timer functions
876
+ * (setTimeout, setInterval, clearTimeout, clearInterval, nextTick,
877
+ * setImmediate and clearImmediate).
878
+ */
879
+ useFakeTimers(): JestObjectType,
880
+ /**
881
+ * Instructs Jest to use the real versions of the standard timer functions.
882
+ */
883
+ useRealTimers(): JestObjectType,
884
+ /**
885
+ * Creates a mock function similar to jest.fn but also tracks calls to
886
+ * object[methodName].
887
+ */
888
+ spyOn(
889
+ object: Object,
890
+ methodName: string,
891
+ accessType?: 'get' | 'set'
892
+ ): JestMockFn<any, any>,
893
+ /**
894
+ * Set the default timeout interval for tests and before/after hooks in milliseconds.
895
+ * Note: The default timeout interval is 5 seconds if this method is not called.
896
+ */
897
+ setTimeout(timeout: number): JestObjectType,
898
+ ...
899
+ };
900
+
901
+ type JestSpyType = { calls: JestCallsType, ... };
902
+
903
+ type JestDoneFn = {|
904
+ (): void,
905
+ fail: (error: Error) => void,
906
+ |};
907
+
908
+ /** Runs this function after every test inside this context */
909
+ declare function afterEach(
910
+ fn: (done: JestDoneFn) => ?Promise<mixed>,
911
+ timeout?: number
912
+ ): void;
913
+ /** Runs this function before every test inside this context */
914
+ declare function beforeEach(
915
+ fn: (done: JestDoneFn) => ?Promise<mixed>,
916
+ timeout?: number
917
+ ): void;
918
+ /** Runs this function after all tests have finished inside this context */
919
+ declare function afterAll(
920
+ fn: (done: JestDoneFn) => ?Promise<mixed>,
921
+ timeout?: number
922
+ ): void;
923
+ /** Runs this function before any tests have started inside this context */
924
+ declare function beforeAll(
925
+ fn: (done: JestDoneFn) => ?Promise<mixed>,
926
+ timeout?: number
927
+ ): void;
928
+
929
+ /** A context for grouping tests together */
930
+ declare var describe: {
931
+ /**
932
+ * Creates a block that groups together several related tests in one "test suite"
933
+ */
934
+ (name: JestTestName, fn: () => void): void,
935
+ /**
936
+ * Only run this describe block
937
+ */
938
+ only(name: JestTestName, fn: () => void): void,
939
+ /**
940
+ * Skip running this describe block
941
+ */
942
+ skip(name: JestTestName, fn: () => void): void,
943
+ /**
944
+ * each runs this test against array of argument arrays per each run
945
+ *
946
+ * @param {table} table of Test
947
+ */
948
+ each(
949
+ ...table: Array<Array<mixed> | mixed> | [Array<string>, string]
950
+ ): (
951
+ name: JestTestName,
952
+ fn?: (...args: Array<any>) => ?Promise<mixed>,
953
+ timeout?: number
954
+ ) => void,
955
+ ...
956
+ };
957
+
958
+ /** An individual test unit */
959
+ declare var it: {
960
+ /**
961
+ * An individual test unit
962
+ *
963
+ * @param {JestTestName} Name of Test
964
+ * @param {Function} Test
965
+ * @param {number} Timeout for the test, in milliseconds.
966
+ */
967
+ (
968
+ name: JestTestName,
969
+ fn?: (done: JestDoneFn) => ?Promise<mixed>,
970
+ timeout?: number
971
+ ): void,
972
+ /**
973
+ * Only run this test
974
+ *
975
+ * @param {JestTestName} Name of Test
976
+ * @param {Function} Test
977
+ * @param {number} Timeout for the test, in milliseconds.
978
+ */
979
+ only: {|
980
+ (
981
+ name: JestTestName,
982
+ fn?: (done: JestDoneFn) => ?Promise<mixed>,
983
+ timeout?: number
984
+ ): void,
985
+ each(
986
+ ...table: Array<Array<mixed> | mixed> | [Array<string>, string]
987
+ ): (
988
+ name: JestTestName,
989
+ fn?: (...args: Array<any>) => ?Promise<mixed>,
990
+ timeout?: number
991
+ ) => void
992
+ |},
993
+ /**
994
+ * Skip running this test
995
+ *
996
+ * @param {JestTestName} Name of Test
997
+ * @param {Function} Test
998
+ * @param {number} Timeout for the test, in milliseconds.
999
+ */
1000
+ skip(
1001
+ name: JestTestName,
1002
+ fn?: (done: JestDoneFn) => ?Promise<mixed>,
1003
+ timeout?: number
1004
+ ): void,
1005
+ /**
1006
+ * Highlight planned tests in the summary output
1007
+ *
1008
+ * @param {String} Name of Test to do
1009
+ */
1010
+ todo(name: string): void,
1011
+ /**
1012
+ * Run the test concurrently
1013
+ *
1014
+ * @param {JestTestName} Name of Test
1015
+ * @param {Function} Test
1016
+ * @param {number} Timeout for the test, in milliseconds.
1017
+ */
1018
+ concurrent(
1019
+ name: JestTestName,
1020
+ fn?: (done: JestDoneFn) => ?Promise<mixed>,
1021
+ timeout?: number
1022
+ ): void,
1023
+ /**
1024
+ * each runs this test against array of argument arrays per each run
1025
+ *
1026
+ * @param {table} table of Test
1027
+ */
1028
+ each(
1029
+ ...table: Array<Array<mixed> | mixed> | [Array<string>, string]
1030
+ ): (
1031
+ name: JestTestName,
1032
+ fn?: (...args: Array<any>) => ?Promise<mixed>,
1033
+ timeout?: number
1034
+ ) => void,
1035
+ ...
1036
+ };
1037
+
1038
+ declare function fit(
1039
+ name: JestTestName,
1040
+ fn: (done: JestDoneFn) => ?Promise<mixed>,
1041
+ timeout?: number
1042
+ ): void;
1043
+ /** An individual test unit */
1044
+ declare var test: typeof it;
1045
+ /** A disabled group of tests */
1046
+ declare var xdescribe: typeof describe;
1047
+ /** A focused group of tests */
1048
+ declare var fdescribe: typeof describe;
1049
+ /** A disabled individual test */
1050
+ declare var xit: typeof it;
1051
+ /** A disabled individual test */
1052
+ declare var xtest: typeof it;
1053
+
1054
+ type JestPrettyFormatColors = {
1055
+ comment: {
1056
+ close: string,
1057
+ open: string,
1058
+ ...
1059
+ },
1060
+ content: {
1061
+ close: string,
1062
+ open: string,
1063
+ ...
1064
+ },
1065
+ prop: {
1066
+ close: string,
1067
+ open: string,
1068
+ ...
1069
+ },
1070
+ tag: {
1071
+ close: string,
1072
+ open: string,
1073
+ ...
1074
+ },
1075
+ value: {
1076
+ close: string,
1077
+ open: string,
1078
+ ...
1079
+ },
1080
+ ...
1081
+ };
1082
+
1083
+ type JestPrettyFormatIndent = string => string;
1084
+ type JestPrettyFormatRefs = Array<any>;
1085
+ type JestPrettyFormatPrint = any => string;
1086
+ type JestPrettyFormatStringOrNull = string | null;
1087
+
1088
+ type JestPrettyFormatOptions = {|
1089
+ callToJSON: boolean,
1090
+ edgeSpacing: string,
1091
+ escapeRegex: boolean,
1092
+ highlight: boolean,
1093
+ indent: number,
1094
+ maxDepth: number,
1095
+ min: boolean,
1096
+ plugins: JestPrettyFormatPlugins,
1097
+ printFunctionName: boolean,
1098
+ spacing: string,
1099
+ theme: {|
1100
+ comment: string,
1101
+ content: string,
1102
+ prop: string,
1103
+ tag: string,
1104
+ value: string,
1105
+ |},
1106
+ |};
1107
+
1108
+ type JestPrettyFormatPlugin = {
1109
+ print: (
1110
+ val: any,
1111
+ serialize: JestPrettyFormatPrint,
1112
+ indent: JestPrettyFormatIndent,
1113
+ opts: JestPrettyFormatOptions,
1114
+ colors: JestPrettyFormatColors
1115
+ ) => string,
1116
+ test: any => boolean,
1117
+ ...
1118
+ };
1119
+
1120
+ type JestPrettyFormatPlugins = Array<JestPrettyFormatPlugin>;
1121
+
1122
+ /** The expect function is used every time you want to test a value */
1123
+ declare var expect: {
1124
+ /** The object that you want to make assertions against */
1125
+ (
1126
+ value: any
1127
+ ): JestExpectType &
1128
+ JestPromiseType &
1129
+ EnzymeMatchersType &
1130
+ DomTestingLibraryType &
1131
+ JestJQueryMatchersType &
1132
+ JestStyledComponentsMatchersType &
1133
+ JestExtendedMatchersType,
1134
+ /** Add additional Jasmine matchers to Jest's roster */
1135
+ extend(matchers: { [name: string]: JestMatcher, ... }): void,
1136
+ /** Add a module that formats application-specific data structures. */
1137
+ addSnapshotSerializer(pluginModule: JestPrettyFormatPlugin): void,
1138
+ assertions(expectedAssertions: number): void,
1139
+ hasAssertions(): void,
1140
+ any(value: mixed): JestAsymmetricEqualityType,
1141
+ anything(): any,
1142
+ arrayContaining(value: Array<mixed>): Array<mixed>,
1143
+ objectContaining(value: Object): Object,
1144
+ /** Matches any received string that contains the exact expected string. */
1145
+ stringContaining(value: string): string,
1146
+ stringMatching(value: string | RegExp): string,
1147
+ not: {
1148
+ arrayContaining: (value: $ReadOnlyArray<mixed>) => Array<mixed>,
1149
+ objectContaining: (value: {...}) => Object,
1150
+ stringContaining: (value: string) => string,
1151
+ stringMatching: (value: string | RegExp) => string,
1152
+ ...
1153
+ },
1154
+ ...
1155
+ };
1156
+
1157
+ // TODO handle return type
1158
+ // http://jasmine.github.io/2.4/introduction.html#section-Spies
1159
+ declare function spyOn(value: mixed, method: string): Object;
1160
+
1161
+ /** Holds all functions related to manipulating test runner */
1162
+ declare var jest: JestObjectType;
1163
+
1164
+ /**
1165
+ * The global Jasmine object, this is generally not exposed as the public API,
1166
+ * using features inside here could break in later versions of Jest.
1167
+ */
1168
+ declare var jasmine: {
1169
+ DEFAULT_TIMEOUT_INTERVAL: number,
1170
+ any(value: mixed): JestAsymmetricEqualityType,
1171
+ anything(): any,
1172
+ arrayContaining(value: Array<mixed>): Array<mixed>,
1173
+ clock(): JestClockType,
1174
+ createSpy(name: string): JestSpyType,
1175
+ createSpyObj(
1176
+ baseName: string,
1177
+ methodNames: Array<string>
1178
+ ): { [methodName: string]: JestSpyType, ... },
1179
+ objectContaining(value: Object): Object,
1180
+ stringMatching(value: string): string,
1181
+ ...
1182
+ };