Skip to content
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

Add possibility to assert action by type and discard payload #15

Open
TristanWright opened this issue Jun 15, 2016 · 1 comment
Open

Comments

@TristanWright
Copy link
Contributor

For some async actions, instead of replicating a lot of data I'd just like to check that an action of a certain type is being dispatched. I'll make a PR for it if you think it's a good idea.

@dmitry-zaets
Copy link
Member

From one side it is a good idea.
From another side - it could hide errors because you will ensure that you are triggering action, but payload can have a mistype.
For example date instead of data: { type: 'some type', date: {...} }

What I can propose is to extend .toDispatchActions with a comparator as second arguments, same as lodash does. Then you will be able to do different types of checks, like :

expect(myAction())
  .toDispatchActions([ { type: 'a' }, { type: 'b' } ]);

expect(myAction())
  .toDispatchActions(
    [ { type: 'a' }, { type: 'b' } ],
    (actual, expected) => actual.type === expected.type
  );

expect(myAction())
  .toDispatchActions(
    [ { type: 'a' }, { type: 'b' } ],
    (actual, expected) => actual.type === expected.type && actual.timestamp === expected.timestamp
  );

@dmitry-zaets dmitry-zaets changed the title .toDispatchActionsWithType() Add possibility to assert action by type and discard payload Jun 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants