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

Allow when & verify to disregard arity #36

Closed
searls opened this issue Oct 24, 2015 · 0 comments
Closed

Allow when & verify to disregard arity #36

searls opened this issue Oct 24, 2015 · 0 comments

Comments

@searls
Copy link
Member

searls commented Oct 24, 2015

#33 implements expected arg length matches actual invocation, which should have been implemented all along (oversight).

This means we should probably provide a way to stub or verify an interaction when we don't care about all the args to work around this. Whatever we do ought to be symmetrical between when & verify's API for ease of understanding.

Some ideas:

drive = td.create()

when(drive(), {ignoreAdditionalArgs: true}).thenReturn("💩")

drive() // "💩"
drive(1,3,4,5) // "💩"

So basically, the second argument to when could be an options object that's stored with the stubbing (or used by the verify) to modify how matching occurs. This gives us some breathing room for other features that would deviate from the default behavior, too.

One more example:

drive = td.create()

when(drive(60), {ignoreAdditionalArgs: true}).thenReturn("💩")

drive() // undefined
drive(60,1,3,4,5) // "💩"
drive(59,1,3,4,5) // undefined

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

1 participant