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
9 changed files
with
147 additions
and
117 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
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
77 changes: 37 additions & 40 deletions
77
src/components/__tests__/__snapshots__/counter_spec.tsx.snap
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,44 +1,41 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`components/Counter renders 1`] = ` | ||
<Loadable(PureCounter) | ||
counter={ | ||
Object { | ||
"value": 0, | ||
} | ||
} | ||
error="" | ||
increment={[Function]} | ||
isLoading={false} | ||
isSaving={false} | ||
label="a counter!" | ||
load={[Function]} | ||
save={[Function]} | ||
store={ | ||
Object { | ||
"dispatch": [Function], | ||
"getState": [Function], | ||
"replaceReducer": [Function], | ||
"subscribe": [Function], | ||
Symbol(observable): [Function], | ||
} | ||
} | ||
storeSubscription={ | ||
Subscription { | ||
"listeners": Object { | ||
"notify": [Function], | ||
}, | ||
"onStateChange": [Function], | ||
"parentSub": undefined, | ||
"store": Object { | ||
"dispatch": [Function], | ||
"getState": [Function], | ||
"replaceReducer": [Function], | ||
"subscribe": [Function], | ||
Symbol(observable): [Function], | ||
}, | ||
"unsubscribe": null, | ||
} | ||
} | ||
/> | ||
<div> | ||
<div | ||
className="hero" | ||
> | ||
<strong> | ||
0 | ||
</strong> | ||
</div> | ||
<form> | ||
<button | ||
onClick={[Function]} | ||
> | ||
click me! | ||
</button> | ||
<button | ||
disabled={false} | ||
onClick={[Function]} | ||
> | ||
save | ||
</button> | ||
<button | ||
disabled={false} | ||
onClick={[Function]} | ||
> | ||
load | ||
</button> | ||
<pre> | ||
{ | ||
"counter": { | ||
"value": 0 | ||
}, | ||
"isSaving": false, | ||
"isLoading": false | ||
} | ||
</pre> | ||
</form> | ||
</div> | ||
`; |
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
12 changes: 11 additions & 1 deletion
12
src/decorators/__tests__/__snapshots__/loadable_spec.tsx.snap
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,3 +1,13 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`decorators/loadable maps props to loading 1`] = `<TestComponent />`; | ||
exports[`decorators/loadable handles loaded state 1`] = ` | ||
<div> | ||
OK | ||
</div> | ||
`; | ||
|
||
exports[`decorators/loadable handles loading state 1`] = ` | ||
<div> | ||
Just a moment, please... | ||
</div> | ||
`; |
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,26 +1,28 @@ | ||
// tslint:disable-next-line no-unused-variable | ||
import * as React from 'react' | ||
import * as TestUtils from 'react-dom/test-utils' | ||
import * as ReactShallowRenderer from 'react-test-renderer/shallow' | ||
import * as TestRenderer from 'react-test-renderer' | ||
|
||
import loadable from '../loadable' | ||
|
||
const TestComponent = () => <div>OK</div> | ||
const LoadableTestComponent = loadable(props => props.isLoading)(TestComponent) | ||
|
||
describe('decorators/loadable', () => { | ||
describe.only('decorators/loadable', () => { | ||
|
||
it('sets friendly .displayName', () => { | ||
expect(LoadableTestComponent.displayName) | ||
const LoadedTestComponent = loadable(() => false)(TestComponent) | ||
expect(LoadedTestComponent.displayName) | ||
.toEqual('Loadable(TestComponent)') | ||
}) | ||
|
||
it('maps props to loading', () => { | ||
const renderer = new ReactShallowRenderer() | ||
expect(renderer.render(<LoadableTestComponent isLoading />).props.children) | ||
.toEqual('Just a moment, please...') | ||
it('handles loading state', () => { | ||
const LoadingTestComponent = loadable(() => true)(TestComponent) | ||
const renderer = TestRenderer.create(<LoadingTestComponent />) | ||
expect(renderer.toJSON()).toMatchSnapshot() | ||
}) | ||
|
||
expect(renderer.render(<LoadableTestComponent />)) | ||
.toMatchSnapshot() | ||
it('handles loaded state', () => { | ||
const LoadedTestComponent = loadable(() => false)(TestComponent) | ||
const renderer = TestRenderer.create(<LoadedTestComponent />) | ||
expect(renderer.toJSON()).toMatchSnapshot() | ||
}) | ||
}) |
Oops, something went wrong.