-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
628 additions
and
337 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,32 @@ | ||
{ | ||
"presets": ["env", "react"], | ||
"plugins": ["transform-flow-strip-types", "transform-class-properties"] | ||
"presets": [ | ||
[ | ||
"env", | ||
{ | ||
"targets": { | ||
"browsers": [ | ||
"Chrome >= 36", | ||
"Edge >= 12", | ||
"Firefox >= 6", | ||
"Explorer >= 11", | ||
"Opera >= 23", | ||
"Safari >= 8", | ||
"Android >= 36", | ||
"ChromeAndroid >= 36", | ||
"FirefoxAndroid >= 6", | ||
"ExplorerMobile >= 11", | ||
"OperaMobile >= 23", | ||
"iOS >= 8" | ||
], | ||
"node": "6" | ||
} | ||
} | ||
], | ||
"react" | ||
], | ||
"plugins": [ | ||
"transform-flow-strip-types", | ||
"transform-class-properties", | ||
"add-module-exports" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
extends: mealsup | ||
|
||
rules: | ||
react-native/no-unused-styles: 0 | ||
|
||
overrides: | ||
- files: "**/*.test.js" | ||
rules: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ install: | |
- yarn install | ||
- yarn check --integrity | ||
script: | ||
- yarn run test:all | ||
- yarn test:all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`When WeakMap is not available throws 1`] = `"\`setFutureState\` requires WeakMap to be available. Consider including a polyfill such as core-js."`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`PureComponentFutureState setFutureState cancelling raw setState triggers the React warning 1`] = ` | ||
exports[`setFutureState cancelling raw setState triggers the React warning 1`] = ` | ||
"Warning: Can only update a mounted or mounting component. This usually means you called setState, replaceState, or forceUpdate on an unmounted component. This is a no-op. | ||
Please check the code for the TestWithResetWarnings-1 component." | ||
`; | ||
|
||
exports[`PureComponentFutureState setFutureState cancelling raw setState triggers the React warning with async 1`] = ` | ||
exports[`setFutureState cancelling raw setState triggers the React warning with async 1`] = ` | ||
"Warning: Can only update a mounted or mounting component. This usually means you called setState, replaceState, or forceUpdate on an unmounted component. This is a no-op. | ||
Please check the code for the TestWithResetWarnings-2 component." | ||
`; | ||
|
||
exports[`PureComponentFutureState setFutureState throws for an incorrect first argument 1`] = ` | ||
exports[`setFutureState throws for an incorrect first argument 1`] = ` | ||
"The first argument to setFutureState() must be a Future or a Function which returns a Promise. | ||
Please check the code for the Test component." | ||
Please check the code for the WithFutureState(TestBase) component." | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// @flow | ||
|
||
import {Component} from 'react' | ||
import withFutureState from './set-future-state' | ||
|
||
type Props = {} | ||
|
||
type State = { | ||
num?: number, | ||
str?: string, | ||
loading: boolean, | ||
} | ||
|
||
export default withFutureState( | ||
setFutureState => | ||
class MyComponent extends Component<Props, State> { | ||
state = { | ||
loading: false, | ||
} | ||
|
||
method() { | ||
// $FlowExpectError | ||
setFutureState() | ||
|
||
// $FlowExpectError | ||
setFutureState(() => Promise.resolve(1), () => ({})) | ||
|
||
// $FlowExpectError | ||
setFutureState({}, () => Promise.resolve(1), () => ({})) | ||
|
||
setFutureState( | ||
this, | ||
() => Promise.resolve(1), | ||
// $FlowExpectError | ||
() => ({other: 'string'}) | ||
) | ||
|
||
setFutureState( | ||
this, | ||
() => Promise.resolve(1), | ||
// $FlowExpectError | ||
(num: string) => ({num, loading: true}) | ||
) | ||
|
||
setFutureState( | ||
this, | ||
() => Promise.resolve(1), | ||
num => ({num, loading: true}) | ||
) | ||
|
||
setFutureState( | ||
this, | ||
() => Promise.resolve(''), | ||
str => ({str, loading: true}) | ||
) | ||
} | ||
|
||
render() { | ||
return 'test' | ||
} | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// @flow | ||
|
||
describe('When WeakMap is not available', () => { | ||
it('throws', () => { | ||
// eslint-disable-next-line no-global-assign, no-native-reassign | ||
WeakMap = void 0 | ||
expect(() => require('./set-future-state')).toThrowErrorMatchingSnapshot() | ||
}) | ||
}) |
Oops, something went wrong.