| OLD | NEW |
| (Empty) | |
| 1 "use strict" |
| 2 |
| 3 sinon = require("sinon") |
| 4 |
| 5 describe "Call count", -> |
| 6 spy = null |
| 7 |
| 8 beforeEach -> |
| 9 spy = sinon.spy() |
| 10 |
| 11 describe "called", -> |
| 12 it "should throw an assertion error when the spy is undefined", -> |
| 13 expect(-> expect(undefined).to.have.been.called).to.throw(TypeError) |
| 14 |
| 15 it "should throw an assertion error when the spy is not called", -> |
| 16 expect(-> spy.should.have.been.called).to.throw(AssertionError) |
| 17 |
| 18 it "should not throw when the spy is called once", -> |
| 19 spy() |
| 20 |
| 21 expect(-> spy.should.have.been.called).to.not.throw() |
| 22 |
| 23 it "should not throw when the spy is called twice", -> |
| 24 spy() |
| 25 spy() |
| 26 |
| 27 expect(-> spy.should.have.been.called).to.not.throw() |
| 28 |
| 29 describe "not called", -> |
| 30 it "should not throw when the spy is not called", -> |
| 31 expect(-> spy.should.not.have.been.called).to.not.throw() |
| 32 |
| 33 it "should throw an assertion error when the spy is called once", -> |
| 34 spy() |
| 35 |
| 36 expect(-> spy.should.not.have.been.called).to.throw(AssertionError) |
| 37 |
| 38 describe "callCount", -> |
| 39 it "should throw an assertion error when the spy is not called", -> |
| 40 expect(-> spy.should.have.callCount()).to.throw(AssertionError) |
| 41 |
| 42 it "should not throw an assertion error when the number of calls equals
provided call count", -> |
| 43 spy() |
| 44 spy() |
| 45 spy() |
| 46 spy() |
| 47 |
| 48 expect(-> spy.should.have.callCount(4)).to.not.throw(AssertionError) |
| 49 |
| 50 it "should throw an assertion error whenever the number of calls are not
equal to provided call count", -> |
| 51 spy() |
| 52 spy() |
| 53 spy() |
| 54 |
| 55 expect(-> spy.should.have.callCount(4)).to.throw(AssertionError) |
| 56 |
| 57 describe "calledOnce", -> |
| 58 it "should throw an assertion error when the spy is not called", -> |
| 59 expect(-> spy.should.have.been.calledOnce).to.throw(AssertionError) |
| 60 |
| 61 it "should not throw when the spy is called once", -> |
| 62 spy() |
| 63 |
| 64 expect(-> spy.should.have.been.calledOnce).to.not.throw() |
| 65 |
| 66 it "should throw an assertion error when the spy is called twice", -> |
| 67 spy() |
| 68 spy() |
| 69 |
| 70 expect(-> spy.should.have.been.calledOnce).to.throw(AssertionError) |
| 71 |
| 72 describe "calledTwice", -> |
| 73 it "should throw an assertion error when the spy is not called", -> |
| 74 expect(-> spy.should.have.been.calledTwice).to.throw(AssertionError) |
| 75 |
| 76 it "should throw an assertion error when the spy is called once", -> |
| 77 spy() |
| 78 |
| 79 expect(-> spy.should.have.been.calledTwice).to.throw(AssertionError) |
| 80 |
| 81 it "should not throw when the spy is called twice", -> |
| 82 spy() |
| 83 spy() |
| 84 |
| 85 expect(-> spy.should.have.been.calledTwice).to.not.throw() |
| 86 |
| 87 it "should throw an assertion error when the spy is called thrice", -> |
| 88 spy() |
| 89 spy() |
| 90 spy() |
| 91 |
| 92 expect(-> spy.should.have.been.calledTwice).to.throw(AssertionError) |
| 93 |
| 94 describe "calledThrice", -> |
| 95 it "should throw an assertion error when the spy is not called", -> |
| 96 expect(-> spy.should.have.been.calledThrice).to.throw(AssertionError
) |
| 97 |
| 98 it "should throw an assertion error when the spy is called once", -> |
| 99 spy() |
| 100 |
| 101 expect(-> spy.should.have.been.calledThrice).to.throw(AssertionError
) |
| 102 |
| 103 it "should throw an assertion error when the spy is called twice", -> |
| 104 spy() |
| 105 spy() |
| 106 |
| 107 expect(-> spy.should.have.been.calledThrice).to.throw(AssertionError
) |
| 108 |
| 109 it "should not throw when the spy is called thrice", -> |
| 110 spy() |
| 111 spy() |
| 112 spy() |
| 113 |
| 114 expect(-> spy.should.have.been.calledThrice).to.not.throw() |
| 115 |
| 116 it "should throw an assertion error when the spy is called four times",
-> |
| 117 spy() |
| 118 spy() |
| 119 spy() |
| 120 spy() |
| 121 |
| 122 expect(-> spy.should.have.been.calledThrice).to.throw(AssertionError
) |
| OLD | NEW |