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

iff() hooks are skipped when there's a .else() #666

Closed
jplespin opened this issue May 30, 2022 · 3 comments
Closed

iff() hooks are skipped when there's a .else() #666

jplespin opened this issue May 30, 2022 · 3 comments

Comments

@jplespin
Copy link
Contributor

Steps to reproduce

Version: 6.1.0 with feathers version 4.5.15

After upgrading from 5.0.6 to 6.1.0, if there's an else, the iff predicate check is skipped and only the else is evaluated. I'm using this in the after hook with something like this:

find: [
  iff(isProvider('server'),
    hookA,
  )
  .else(
    iff(hook => hook.path === 'users', hook6, hook7)
  )
]

This works fine if it's only iff .

The easiest way I found to reproduce this is to add a missing unit tests in if-esle.test.ts and do npm run test which fails for that specific use case.
This is the test I added to check:

  it('using iff(true, ...).else(...)', () => {
    return iff(true,
      hookFcnSync,
      hookFcnSync,
      hookFcnSync
    )
      .else(
        hookFcnSync
      )(hook)
      // @ts-ignore
      .then((hook: any) => {
        assert.equal(hookFcnSyncCalls, 3);
        assert.equal(hookFcnAsyncCalls, 0);
        assert.equal(hookFcnCalls, 0);

        assert.deepEqual(hook, hookAfter);
      });
  });

From what I can tell, I think that this might have been introduced with the 6.0 ts port.
Is this already a known issue? Am I using this wrong?

@fratzinger
Copy link
Collaborator

Please try again with v6.1.1 and close this issue if this version fixes your issue :)

@jplespin
Copy link
Contributor Author

Yeah, that fixed it. Thanks a lot!

@fratzinger
Copy link
Collaborator

Nice. Thanks for your contribution!

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