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 withContext option #207

Open
searls opened this issue Mar 15, 2017 · 0 comments
Open

add withContext option #207

searls opened this issue Mar 15, 2017 · 0 comments

Comments

@searls
Copy link
Member

searls commented Mar 15, 2017

Proposal: allow test double stubbing/verification configuration to specify the value of this that's bound when the test double function is called.

td.when(myTd(), {withContext: window})).thenReturn(5)

myTd() // undefined
myTd.bind(window)() // 5

And for verify:

myTd()
td.verify(myTd(), {withContext: window})) // blows up

myTd.bind(window)()
td.verify(myTd(), {withContext: window})) // passes

Also, argument matchers should be supported:

myTd.bind(new Promise())()
td.verify(myTd(), {withContext: td.matchers.argThat(arg => arg instanceof Promise)})) // passes

Thoughts?

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