react-resizable 1.7.5 → 1.11.0

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