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

How to chain multiple expectations #40

Open
pandaiolo opened this issue Nov 23, 2020 · 1 comment
Open

How to chain multiple expectations #40

pandaiolo opened this issue Nov 23, 2020 · 1 comment

Comments

@pandaiolo
Copy link

Sorry if the issues are not the correct place to ask a question!

I'd like to assert that an action is causing some other actions to trigger, but not others.

For example, doStuff() should trigger fooHappened() but not barDidNot()

Example code that I would like to build:

it('does stuff as expected', async done => {
  expect(doStuff())
    .toDispatchActions([fooHappened()], done)
    .toNotDispatchActions([barDidNot()], done)
})

Two things seem problematic above:

  1. Chaining the expectations? (I think not)
  2. Async management: calling done two times is probably going to break?

Currently, I'm making two different tests to assert for the same action, one to check what triggers as expected, one to check what is not triggered as expected

Is this the right way to do it?

Thanks for the hints.

@dmitry-zaets
Copy link
Member

Hi, unfortunately with the current implementation it is not possible to chain the assertions, but I think you can just do two asserts one by one, something like this (not sure about using the awaits though):

it('does stuff as expected', async () => {
  const action = await doStuff()
  await expect(action).toDispatchActions([fooHappened()])
  await expect(action).toNotDispatchActions([barDidNot()])
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants