Closed artemave closed 13 years ago
This is actually intended. sinon.test is a utility to wrap a test function to sandbox it. It's the fast-lane integration with a test framework. The more "proper" way to integrate is to build a sandbox into the test execution (which e.g. the QUnit adapter does).
You'll have forgive me cluelessness, but the examples - coffeescript? I'm not familiar with its syntax, so I'm not entirely sure of the differences between those two.
Right. It clicked. My bad. The actual expected usage is:
it "should check if user is set", sinon.test ->
User = current: this.spy()
app = new AppController
( expect User.current.called ).toBeTruthy()
which works perfectly. Thanks!
Yes, it is coffeescript. And it totally rocks!
Syntax (in the above examples) is easy to decipher: ->
is function() {}
the rest is just lack of parenthesis in favor of indentation.
Ah, that's good news. Syntax still looks foreign to me, but glad you enjoy it - and made Sinon work :)
The expected usage:
Does nothing unless
sinon.test
is wrapped in function invocation:The reason becomes apparent when examining how
sinon.test
is defined - it returns function.