-
Notifications
You must be signed in to change notification settings - Fork 16.6k
Added tests #1242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added tests #1242
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm having trouble figuring this one out. I looked at multiple docs for testing ajax action creators, sinon fakeServer, nock etc. I think http://redux.js.org/docs/recipes/WritingTests.html seems to make more sense. I kind of modified some of it, but this test keeps failing. Saying the actual callCount of dispatch is 1 instead of 5. I figure the dispatch callcount may not take callbacks into account. Still trying to figure this out.
b915f78 to
93247a4
Compare
93247a4 to
6f5e265
Compare
5fa4124 to
78bee0d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if we test that the expected actions were called and not how many times dispatch was called? it looks like that's what the example is doing:
nock('http://example.com/')
.get('/todos')
.reply(200, { body: { todos: ['do something'] }})
const expectedActions = [
{ type: types.FETCH_TODOS_REQUEST },
{ type: types.FETCH_TODOS_SUCCESS, body: { todos: ['do something'] } }
]
const store = mockStore({ todos: [] })
return store.dispatch(actions.fetchTodos())
.then(() => { // return of async actions
expect(store.getActions()).toEqual(expectedActions)
})
})const expectedActions = [
{ type: types.SET_TIME_COLUMN_OPTS },
{ type: types.SET_TIME_GRAIN_OPTS },
{...},
]There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it but it says 'Cannot read property 'then' of undefined'. It seems that the ajax call never returned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it but it didn't work, it says 'then' can't be called on undefined. I think somehow the ajax request never returned on the nock
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here's an example spec that tests fetching from an API that the redux best practices doc references...
https://git.musta.ch/airbnb/airbnb/pull/44253/files#diff-1e402f9922b2b08b8ef90a58502d4c6bR56
maybe we can use that pattern?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
asking in #frontend-goalie might be helpful too...
…pache#1205) * create structure for new forked explore view (apache#1099) * create structure for new forked explore view * update component name * add bootstrap data pattern * remove console.log * Associate version to entry files (apache#1060) * Associate version to entry files * Modified path joins for configs * Made changes based on comments * Created store and reducers (apache#1108) * Created store and reducers * Added spec * Modifications based on comments * Explore control panel components: Chart control, Time filter, SQL, GroupBy and Filters * Modifications based on comments
b943eac to
2dfac09
Compare
2dfac09 to
6f8827d
Compare
| ACCESS_REQUEST_MISSING_ERR = __( | ||
| "The access requests seem to have been deleted") | ||
| USER_MISSING_ERR = __("The user seems to have been deleted") | ||
| DATASOURCE_ACCESS_ERR = __("User does not have access to this datasource") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry forgot to add this for last PR, adding it here
|
Build is failing, conflicts, imprecise commit message. I'm closing, you can re-open if needed when ready. |
Done:
Todo:
help-needed @ascott