What is the difference between
stub.yield([arg1, arg2, ...])
spy.yields([arg1, arg2, ...])
stub.callsArg(index)
in the Sinon.js stub library?
stub.yield()
is the only one that I've been able to grasp:
stub = sinon.stub(API, 'call_remote');
callback = sinon.spy();
API.call_remote('help', callback);
@stub.yield( "solution!" );
@stub.calledOnce.should.be.true;
@callback.calledOnce.should.be.true;
@callback.args[0][0].should.eql( "solution!" );
As tested with should.js, would have all assertions pass.
Are there similar test patterns for stub.yields()
and stub.callsArg(index)
?
The documentation does not provide any examples to clarify these other two methods but I am curious about them.