Skip to content

example tests #788

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

Closed
svnlto opened this issue Sep 23, 2015 · 6 comments
Closed

example tests #788

svnlto opened this issue Sep 23, 2015 · 6 comments
Labels

Comments

@svnlto
Copy link

svnlto commented Sep 23, 2015

I'm looking for help in creating tests for the 'real-world' example. Could you point out of the write tests for these kind of action creators?

@gaearon
Copy link
Contributor

gaearon commented Sep 23, 2015

Woah, cool, thanks for taking a look at this!
Please see #546.

@svnlto
Copy link
Author

svnlto commented Sep 23, 2015

Sure, no problem. Maybe I didn't express myself properly tho. I'm having trouble writing tests for those kind of actions creators. mind providing some pointers?

@gaearon
Copy link
Contributor

gaearon commented Sep 23, 2015

Can you explain the problem more specifically? Maybe I'm missing the point as to what exactly you're looking to test.

@gaearon gaearon reopened this Sep 23, 2015
@svnlto
Copy link
Author

svnlto commented Sep 23, 2015

Sure. I'm attempting to write a test for https://github.com/rackt/redux/blob/master/examples/real-world/actions/index.js#L3-L17 based on the action creators test example in the docs. But when I call actions.fetchUser(someString) all I get back is {}.

The test example in the docs makes perfect sense, It's just not clear to me how I'd write a test for an action creator that uses a "custom" middleware.

@gaearon
Copy link
Contributor

gaearon commented Sep 23, 2015

Oh, that's just because it puts the middleware-specific stuff behind a symbol. You can read it the same way it is written:

import { CALL_API } from '../middleware/api';
import { fetchUser } from '../actions';

expect(fetchUser('svnlto')[CALL_API].endpoint).toEqual('/users/svnlto');

I'm not sure how useful it is to test these things, as tests will look pretty much the same as functions themselves. These are just descriptions after all. You might want to test the middleware itself instead.

@svnlto
Copy link
Author

svnlto commented Sep 23, 2015

You might want to test the middleware itself instead.

Yeah, thinking about it, this would make much more sense.

@gaearon gaearon closed this as completed Sep 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants