Last active
October 22, 2017 23:17
-
-
Save lmatteis/f174bfef532045e176a5960f2cdecbe3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
reduxTdd({ items, error, loading, pages }, state => [ | |
<List | |
items={getItems(state)} />, | |
<Loading | |
loading={state.loading} />, | |
<RefreshButton | |
onClick={refreshAction} />, | |
<Error | |
message={state.error} />, | |
<Pages | |
pages={getPages(state)} | |
onPageClick={selectPageAction} /> | |
]) | |
.it('should not show any items') | |
.contains(<Item />, false) | |
.it('should click on refresh button') | |
.switch(RefreshButton) | |
.action(props => props.onClick()) | |
.it('should show loading') | |
.switch(Loading) | |
.toMatchProps({ loading: true }) | |
.it('should trigger a successful HTTP response') | |
.epic(handleRefreshEpic, { getJSON: () => | |
Observable.of([ | |
{ name: 'redux-tdd' }, { name: 'redux-cycles' }, { name: 'foo bar'} | |
]) | |
}) | |
.it('should show items based on the number of page selected') | |
.switch(List) | |
.toMatchProps({ items: [ | |
{ name: 'redux-tdd' }, { name: 'redux-cycles' } | |
]}) | |
.it('should hide loading') | |
.switch(Loading) | |
.toMatchProps({ loading: false }) | |
.it('should render correct amount of pages') | |
.switch(Pages) | |
.toMatchProps({ pages: [0, 1] }) | |
.it('should select second page (index 1)') | |
.action(props => props.onPageClick(1)) | |
.it('should show items based on second page') | |
.switch(List) | |
.toMatchProps({ items: [ | |
{ name: 'foo bar' } | |
]}) | |
.it('should trigger an error response') | |
.switch(RefreshButton) | |
.action(props => props.onClick()) | |
.epic(handleRefreshEpic, { getJSON: () => | |
Observable.throw({ error: 'Some error' }) | |
}) | |
.it('should test that Error component got right error message') | |
.switch(Error) | |
.toMatchProps({ | |
message: 'Some error' | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment