Skip to content

Commit 78fc8c4

Browse files
authored
Merge pull request #124 from springload/chore/babel-7
Chore/babel 7
2 parents cb0ca7a + c697292 commit 78fc8c4

File tree

5 files changed

+10312
-7675
lines changed

5 files changed

+10312
-7675
lines changed

.babelrc

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
{
22
"presets": [
33
[
4-
"env",
4+
"@babel/preset-env",
55
{
66
"modules": false
77
}
88
],
9-
"react",
10-
"stage-2"
9+
"@babel/preset-react",
10+
"@babel/preset-flow"
1111
],
1212
"env": {
1313
"test": {
14-
"presets": ["env", "react", "stage-2"]
14+
"presets": ["@babel/preset-env", "@babel/preset-react"],
1515
}
16-
}
16+
},
17+
"plugins": ["@babel/plugin-proposal-class-properties"]
1718
}

demo/js/demo.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint no-console: 0 */
22
// eslint-disable-next-line import/no-extraneous-dependencies
3-
import 'babel-polyfill';
3+
import '@babel/polyfill';
44
import React from 'react';
55
import ReactDOM from 'react-dom';
66

flow-typed/npm/jest_v22.x.x.js renamed to flow-typed/npm/jest_v23.x.x.js

+137-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// flow-typed signature: 5f6b80ba0fa4571aac1e7ea6e5fea425
2-
// flow-typed version: f4a7859cd3/jest_v22.x.x/flow_>=v0.39.x
1+
// flow-typed signature: f5a484315a3dea13d273645306e4076a
2+
// flow-typed version: 7c5d14b3d4/jest_v23.x.x/flow_>=v0.39.x
33

44
type JestMockFn<TArguments: $ReadOnlyArray<*>, TReturn> = {
55
(...args: TArguments): TReturn,
@@ -65,13 +65,29 @@ type JestMockFn<TArguments: $ReadOnlyArray<*>, TReturn> = {
6565
*/
6666
mockReturnThis(): void,
6767
/**
68-
* Deprecated: use jest.fn(() => value) instead
68+
* Accepts a value that will be returned whenever the mock function is called.
6969
*/
7070
mockReturnValue(value: TReturn): JestMockFn<TArguments, TReturn>,
7171
/**
7272
* Sugar for only returning a value once inside your mock
7373
*/
74-
mockReturnValueOnce(value: TReturn): JestMockFn<TArguments, TReturn>
74+
mockReturnValueOnce(value: TReturn): JestMockFn<TArguments, TReturn>,
75+
/**
76+
* Sugar for jest.fn().mockImplementation(() => Promise.resolve(value))
77+
*/
78+
mockResolvedValue(value: TReturn): JestMockFn<TArguments, Promise<TReturn>>,
79+
/**
80+
* Sugar for jest.fn().mockImplementationOnce(() => Promise.resolve(value))
81+
*/
82+
mockResolvedValueOnce(value: TReturn): JestMockFn<TArguments, Promise<TReturn>>,
83+
/**
84+
* Sugar for jest.fn().mockImplementation(() => Promise.reject(value))
85+
*/
86+
mockRejectedValue(value: TReturn): JestMockFn<TArguments, Promise<any>>,
87+
/**
88+
* Sugar for jest.fn().mockImplementationOnce(() => Promise.reject(value))
89+
*/
90+
mockRejectedValueOnce(value: TReturn): JestMockFn<TArguments, Promise<any>>
7591
};
7692

7793
type JestAsymmetricEqualityType = {
@@ -124,6 +140,30 @@ type JestPromiseType = {
124140
*/
125141
type JestTestName = string | Function;
126142

143+
/**
144+
* Plugin: jest-styled-components
145+
*/
146+
147+
type JestStyledComponentsMatcherValue =
148+
| string
149+
| JestAsymmetricEqualityType
150+
| RegExp
151+
| typeof undefined;
152+
153+
type JestStyledComponentsMatcherOptions = {
154+
media?: string;
155+
modifier?: string;
156+
supports?: string;
157+
}
158+
159+
type JestStyledComponentsMatchersType = {
160+
toHaveStyleRule(
161+
property: string,
162+
value: JestStyledComponentsMatcherValue,
163+
options?: JestStyledComponentsMatcherOptions
164+
): void,
165+
};
166+
127167
/**
128168
* Plugin: jest-enzyme
129169
*/
@@ -483,8 +523,14 @@ type JestExtendedMatchersType = {
483523
toIncludeMultiple(substring: string[]): void;
484524
};
485525

486-
type JestExpectType = {
487-
not: JestExpectType & EnzymeMatchersType & DomTestingLibraryType & JestJQueryMatchersType & JestExtendedMatchersType,
526+
interface JestExpectType {
527+
not:
528+
& JestExpectType
529+
& EnzymeMatchersType
530+
& DomTestingLibraryType
531+
& JestJQueryMatchersType
532+
& JestStyledComponentsMatchersType
533+
& JestExtendedMatchersType,
488534
/**
489535
* If you have a mock function, you can use .lastCalledWith to test what
490536
* arguments it was last called with.
@@ -495,10 +541,6 @@ type JestExpectType = {
495541
* strict equality.
496542
*/
497543
toBe(value: any): void,
498-
/**
499-
* Use .toHaveBeenCalled to ensure that a mock function got called.
500-
*/
501-
toBeCalled(): void,
502544
/**
503545
* Use .toBeCalledWith to ensure that a mock function was called with
504546
* specific arguments.
@@ -574,21 +616,55 @@ type JestExpectType = {
574616
* Use .toHaveBeenCalled to ensure that a mock function got called.
575617
*/
576618
toHaveBeenCalled(): void,
619+
toBeCalled(): void;
577620
/**
578621
* Use .toHaveBeenCalledTimes to ensure that a mock function got called exact
579622
* number of times.
580623
*/
581624
toHaveBeenCalledTimes(number: number): void,
625+
toBeCalledTimes(number: number): void;
626+
/**
627+
*
628+
*/
629+
toHaveBeenNthCalledWith(nthCall: number, ...args: Array<any>): void;
630+
nthCalledWith(nthCall: number, ...args: Array<any>): void;
631+
/**
632+
*
633+
*/
634+
toHaveReturned(): void;
635+
toReturn(): void;
636+
/**
637+
*
638+
*/
639+
toHaveReturnedTimes(number: number): void;
640+
toReturnTimes(number: number): void;
641+
/**
642+
*
643+
*/
644+
toHaveReturnedWith(value: any): void;
645+
toReturnWith(value: any): void;
646+
/**
647+
*
648+
*/
649+
toHaveLastReturnedWith(value: any): void;
650+
lastReturnedWith(value: any): void;
651+
/**
652+
*
653+
*/
654+
toHaveNthReturnedWith(nthCall: number, value: any): void;
655+
nthReturnedWith(nthCall: number, value: any): void;
582656
/**
583657
* Use .toHaveBeenCalledWith to ensure that a mock function was called with
584658
* specific arguments.
585659
*/
586660
toHaveBeenCalledWith(...args: Array<any>): void,
661+
toBeCalledWith(...args: Array<any>): void,
587662
/**
588663
* Use .toHaveBeenLastCalledWith to ensure that a mock function was last called
589664
* with specific arguments.
590665
*/
591666
toHaveBeenLastCalledWith(...args: Array<any>): void,
667+
lastCalledWith(...args: Array<any>): void,
592668
/**
593669
* Check that an object has a .length property and it is set to a certain
594670
* numeric value.
@@ -607,9 +683,20 @@ type JestExpectType = {
607683
*/
608684
toMatchObject(object: Object | Array<Object>): void,
609685
/**
610-
* This ensures that a React component matches the most recent snapshot.
686+
* Use .toStrictEqual to check that a javascript object matches a subset of the properties of an object.
687+
*/
688+
toStrictEqual(value: any): void,
689+
/**
690+
* This ensures that an Object matches the most recent snapshot.
611691
*/
612-
toMatchSnapshot(name?: string): void,
692+
toMatchSnapshot(propertyMatchers?: {[key: string]: JestAsymmetricEqualityType}, name?: string): void,
693+
/**
694+
* This ensures that an Object matches the most recent snapshot.
695+
*/
696+
toMatchSnapshot(name: string): void,
697+
698+
toMatchInlineSnapshot(snapshot?: string): void,
699+
toMatchInlineSnapshot(propertyMatchers?: {[key: string]: JestAsymmetricEqualityType}, snapshot?: string): void,
613700
/**
614701
* Use .toThrow to test that a function throws when it is called.
615702
* If you want to test that a specific error gets thrown, you can provide an
@@ -624,8 +711,9 @@ type JestExpectType = {
624711
* Use .toThrowErrorMatchingSnapshot to test that a function throws a error
625712
* matching the most recent snapshot when it is called.
626713
*/
627-
toThrowErrorMatchingSnapshot(): void
628-
};
714+
toThrowErrorMatchingSnapshot(): void,
715+
toThrowErrorMatchingInlineSnapshot(snapshot?: string): void,
716+
}
629717

630718
type JestObjectType = {
631719
/**
@@ -843,6 +931,17 @@ declare var it: {
843931
fn?: (done: () => void) => ?Promise<mixed>,
844932
timeout?: number
845933
): void,
934+
/**
935+
* each runs this test against array of argument arrays per each run
936+
*
937+
* @param {table} table of Test
938+
*/
939+
each(
940+
table: Array<Array<mixed>>
941+
): (
942+
name: JestTestName,
943+
fn?: (...args: Array<any>) => ?Promise<mixed>
944+
) => void,
846945
/**
847946
* Only run this test
848947
*
@@ -854,7 +953,14 @@ declare var it: {
854953
name: JestTestName,
855954
fn?: (done: () => void) => ?Promise<mixed>,
856955
timeout?: number
857-
): void,
956+
): {
957+
each(
958+
table: Array<Array<mixed>>
959+
): (
960+
name: JestTestName,
961+
fn?: (...args: Array<any>) => ?Promise<mixed>
962+
) => void,
963+
},
858964
/**
859965
* Skip running this test
860966
*
@@ -945,7 +1051,15 @@ type JestPrettyFormatPlugins = Array<JestPrettyFormatPlugin>;
9451051
/** The expect function is used every time you want to test a value */
9461052
declare var expect: {
9471053
/** The object that you want to make assertions against */
948-
(value: any): JestExpectType & JestPromiseType & EnzymeMatchersType & DomTestingLibraryType & JestJQueryMatchersType & JestExtendedMatchersType,
1054+
(value: any):
1055+
& JestExpectType
1056+
& JestPromiseType
1057+
& EnzymeMatchersType
1058+
& DomTestingLibraryType
1059+
& JestJQueryMatchersType
1060+
& JestStyledComponentsMatchersType
1061+
& JestExtendedMatchersType,
1062+
9491063
/** Add additional Jasmine matchers to Jest's roster */
9501064
extend(matchers: { [name: string]: JestMatcher }): void,
9511065
/** Add a module that formats application-specific data structures. */
@@ -958,7 +1072,13 @@ declare var expect: {
9581072
objectContaining(value: Object): Object,
9591073
/** Matches any received string that contains the exact expected string. */
9601074
stringContaining(value: string): string,
961-
stringMatching(value: string | RegExp): string
1075+
stringMatching(value: string | RegExp): string,
1076+
not: {
1077+
arrayContaining: (value: $ReadOnlyArray<mixed>) => Array<mixed>,
1078+
objectContaining: (value: {}) => Object,
1079+
stringContaining: (value: string) => string,
1080+
stringMatching: (value: string | RegExp) => string,
1081+
},
9621082
};
9631083

9641084
// TODO handle return type

0 commit comments

Comments
 (0)