| OLD | NEW |
| (Empty) | |
| 1 "use strict" |
| 2 |
| 3 sinon = require("sinon") |
| 4 |
| 5 describe "Calling with new", -> |
| 6 spy = null |
| 7 |
| 8 beforeEach -> |
| 9 spy = sinon.spy() |
| 10 |
| 11 describe "calledWithNew", -> |
| 12 it "should throw an assertion error if the spy is never called", -> |
| 13 expect(-> spy.should.have.been.calledWithNew).to.throw(AssertionErro
r) |
| 14 |
| 15 it "should throw an assertion error if the spy is called without `new`",
-> |
| 16 spy() |
| 17 |
| 18 expect(-> spy.should.have.been.calledWithNew).to.throw(AssertionErro
r) |
| 19 expect(-> spy.getCall(0).should.have.been.calledWithNew).to.throw(As
sertionError) |
| 20 |
| 21 it "should not throw if the spy is called with `new`", -> |
| 22 new spy() |
| 23 |
| 24 expect(-> spy.should.have.been.calledWithNew).to.not.throw() |
| 25 expect(-> spy.getCall(0).should.have.been.calledWithNew).to.not.thro
w() |
| 26 |
| 27 it "should not throw if the spy is called with `new` and also without `n
ew`", -> |
| 28 spy() |
| 29 new spy() |
| 30 |
| 31 expect(-> spy.should.have.been.calledWithNew).to.not.throw() |
| 32 expect(-> spy.getCall(1).should.have.been.calledWithNew).to.not.thro
w() |
| 33 |
| 34 describe "always calledWithNew", -> |
| 35 it "should throw an assertion error if the spy is never called", -> |
| 36 expect(-> spy.should.always.have.been.calledWithNew).to.throw(Assert
ionError) |
| 37 expect(-> spy.should.have.always.been.calledWithNew).to.throw(Assert
ionError) |
| 38 expect(-> spy.should.have.been.always.calledWithNew).to.throw(Assert
ionError) |
| 39 |
| 40 it "should throw an assertion error if the spy is called without `new`",
-> |
| 41 spy() |
| 42 |
| 43 expect(-> spy.should.always.have.been.calledWithNew).to.throw(Assert
ionError) |
| 44 expect(-> spy.should.have.always.been.calledWithNew).to.throw(Assert
ionError) |
| 45 expect(-> spy.should.have.been.always.calledWithNew).to.throw(Assert
ionError) |
| 46 |
| 47 it "should not throw if the spy is called with `new`", -> |
| 48 new spy() |
| 49 |
| 50 expect(-> spy.should.always.have.been.calledWithNew).to.not.throw() |
| 51 expect(-> spy.should.have.always.been.calledWithNew).to.not.throw() |
| 52 expect(-> spy.should.have.been.always.calledWithNew).to.not.throw() |
| 53 |
| 54 it "should throw an assertion error if the spy is called with `new` and
also without `new`", -> |
| 55 spy() |
| 56 new spy() |
| 57 |
| 58 expect(-> spy.should.always.have.been.calledWithNew).to.throw(Assert
ionError) |
| 59 expect(-> spy.should.have.always.been.calledWithNew).to.throw(Assert
ionError) |
| 60 expect(-> spy.should.have.been.always.calledWithNew).to.throw(Assert
ionError) |
| 61 |
| 62 |
| OLD | NEW |