| Index: appengine/config_service/ui/bower_components/sinon-chai/test/returning.coffee
|
| diff --git a/appengine/config_service/ui/bower_components/sinon-chai/test/returning.coffee b/appengine/config_service/ui/bower_components/sinon-chai/test/returning.coffee
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..22c04100ab4482915a6507d81642f7962c97098f
|
| --- /dev/null
|
| +++ b/appengine/config_service/ui/bower_components/sinon-chai/test/returning.coffee
|
| @@ -0,0 +1,60 @@
|
| +"use strict"
|
| +
|
| +sinon = require("sinon")
|
| +
|
| +describe "Returning", ->
|
| + describe "returned", ->
|
| + it "should throw an assertion error if the spy does not return the correct value", ->
|
| + spy = sinon.spy.create(-> 1)
|
| +
|
| + spy()
|
| +
|
| + expect(-> spy.should.have.returned(2)).to.throw(AssertionError)
|
| + expect(-> spy.getCall(0).should.have.returned(2)).to.throw(AssertionError)
|
| +
|
| + it "should not throw if the spy returns the correct value", ->
|
| + spy = sinon.spy.create(-> 1)
|
| +
|
| + spy()
|
| +
|
| + expect(-> spy.should.have.returned(1)).to.not.throw()
|
| + expect(-> spy.getCall(0).should.have.returned(1)).to.not.throw()
|
| +
|
| + it "should not throw if the spy returns the correct value amongst others", ->
|
| + values = [1, 2, 3]
|
| + spy = sinon.spy.create(-> values[spy.callCount - 1])
|
| +
|
| + spy()
|
| + spy()
|
| + spy()
|
| +
|
| + expect(-> spy.should.have.returned(1)).to.not.throw()
|
| + expect(-> spy.getCall(0).should.have.returned(1)).to.not.throw()
|
| +
|
| + describe "always returned", ->
|
| + it "should throw an assertion error if the spy does not return the correct value", ->
|
| + spy = sinon.spy.create(-> 1)
|
| +
|
| + spy()
|
| +
|
| + expect(-> spy.should.always.have.returned(2)).to.throw(AssertionError)
|
| + expect(-> spy.should.have.always.returned(2)).to.throw(AssertionError)
|
| +
|
| + it "should not throw if the spy returns the correct value", ->
|
| + spy = sinon.spy.create(-> 1)
|
| +
|
| + spy()
|
| +
|
| + expect(-> spy.should.have.always.returned(1)).to.not.throw()
|
| + expect(-> spy.should.always.have.returned(1)).to.not.throw()
|
| +
|
| + it "should throw an assertion error if the spy returns the correct value amongst others", ->
|
| + values = [1, 2, 3]
|
| + spy = sinon.spy.create(-> values[spy.callCount - 1])
|
| +
|
| + spy()
|
| + spy()
|
| + spy()
|
| +
|
| + expect(-> spy.should.always.have.returned(1)).to.throw(AssertionError)
|
| + expect(-> spy.should.have.always.returned(1)).to.throw(AssertionError)
|
|
|