| OLD | NEW |
| (Empty) | |
| 1 "use strict" |
| 2 |
| 3 sinon = require("sinon") |
| 4 |
| 5 describe "Call order", -> |
| 6 spy1 = null |
| 7 spy2 = null |
| 8 spy3 = null |
| 9 |
| 10 beforeEach -> |
| 11 spy1 = sinon.spy() |
| 12 spy2 = sinon.spy() |
| 13 spy3 = sinon.spy() |
| 14 |
| 15 describe "spy1 calledBefore spy2", -> |
| 16 it "should throw an assertion error when neither spy is called", -> |
| 17 expect(-> spy1.should.have.been.calledBefore(spy2)).to.throw(Asserti
onError) |
| 18 |
| 19 it "should not throw when only spy 1 is called", -> |
| 20 spy1() |
| 21 |
| 22 expect(-> spy1.should.have.been.calledBefore(spy2)).to.not.throw() |
| 23 |
| 24 it "should throw an assertion error when only spy 2 is called", -> |
| 25 spy2() |
| 26 |
| 27 expect(-> spy1.should.have.been.calledBefore(spy2)).to.throw(Asserti
onError) |
| 28 |
| 29 it "should not throw when spy 1 is called before spy 2", -> |
| 30 spy1() |
| 31 spy2() |
| 32 |
| 33 expect(-> spy1.should.have.been.calledBefore(spy2)).to.not.throw() |
| 34 |
| 35 it "should throw an assertion error when spy 1 is called after spy 2", -
> |
| 36 spy2() |
| 37 spy1() |
| 38 |
| 39 expect(-> spy1.should.have.been.calledBefore(spy2)).to.throw(Asserti
onError) |
| 40 |
| 41 describe "spy1 calledImmediatelyBefore spy2", -> |
| 42 it "should throw an assertion error when neither spy is called", -> |
| 43 expect(-> spy1.should.have.been.calledImmediatelyBefore(spy2)).to.th
row(AssertionError) |
| 44 |
| 45 it "should throw an assertion error when only spy 1 is called", -> |
| 46 spy1() |
| 47 |
| 48 expect(-> spy1.should.have.been.calledImmediatelyBefore(spy2)).to.th
row(AssertionError) |
| 49 |
| 50 it "should throw an assertion error when only spy 2 is called", -> |
| 51 spy2() |
| 52 |
| 53 expect(-> spy1.should.have.been.calledImmediatelyBefore(spy2)).to.th
row(AssertionError) |
| 54 |
| 55 it "should not throw when spy 1 is called immediately before spy 2", -> |
| 56 spy1() |
| 57 spy2() |
| 58 |
| 59 expect(-> spy1.should.have.been.calledImmediatelyBefore(spy2)).to.no
t.throw() |
| 60 |
| 61 it "should throw an assertion error when spy 1 is called before spy 2, b
ut not immediately", -> |
| 62 spy2() |
| 63 spy3() |
| 64 spy1() |
| 65 |
| 66 expect(-> spy1.should.have.been.calledImmediatelyBefore(spy2)).to.th
row(AssertionError) |
| 67 |
| 68 it "should throw an assertion error when spy 1 is called after spy 2", -
> |
| 69 spy2() |
| 70 spy1() |
| 71 |
| 72 expect(-> spy1.should.have.been.calledImmediatelyBefore(spy2)).to.th
row(AssertionError) |
| 73 |
| 74 describe "spy1 calledAfter spy2", -> |
| 75 it "should throw an assertion error when neither spy is called", -> |
| 76 expect(-> spy1.should.have.been.calledAfter(spy2)).to.throw(Assertio
nError) |
| 77 |
| 78 it "should throw an assertion error when only spy 1 is called", -> |
| 79 spy1() |
| 80 |
| 81 expect(-> spy1.should.have.been.calledAfter(spy2)).to.throw(Assertio
nError) |
| 82 |
| 83 it "should throw an assertion error when only spy 2 is called", -> |
| 84 spy2() |
| 85 |
| 86 expect(-> spy1.should.have.been.calledAfter(spy2)).to.throw(Assertio
nError) |
| 87 |
| 88 it "should throw an assertion error when spy 1 is called before spy 2",
-> |
| 89 spy1() |
| 90 spy2() |
| 91 |
| 92 expect(-> spy1.should.have.been.calledAfter(spy2)).to.throw(Assertio
nError) |
| 93 |
| 94 it "should not throw when spy 1 is called after spy 2", -> |
| 95 spy2() |
| 96 spy1() |
| 97 |
| 98 expect(-> spy1.should.have.been.calledAfter(spy2)).to.not.throw() |
| 99 |
| 100 describe "spy1 calledImmediatelyAfter spy2", -> |
| 101 it "should throw an assertion error when neither spy is called", -> |
| 102 expect(-> spy1.should.have.been.calledImmediatelyAfter(spy2)).to.thr
ow(AssertionError) |
| 103 |
| 104 it "should throw an assertion error when only spy 1 is called", -> |
| 105 spy1() |
| 106 |
| 107 expect(-> spy1.should.have.been.calledImmediatelyAfter(spy2)).to.thr
ow(AssertionError) |
| 108 |
| 109 it "should throw an assertion error when only spy 2 is called", -> |
| 110 spy2() |
| 111 |
| 112 expect(-> spy1.should.have.been.calledImmediatelyAfter(spy2)).to.thr
ow(AssertionError) |
| 113 |
| 114 it "should throw an assertion error when spy 1 is called before spy 2",
-> |
| 115 spy1() |
| 116 spy2() |
| 117 |
| 118 expect(-> spy1.should.have.been.calledImmediatelyAfter(spy2)).to.thr
ow(AssertionError) |
| 119 |
| 120 it "should not throw when spy 1 is called immediately after spy 2", -> |
| 121 spy2() |
| 122 spy1() |
| 123 |
| 124 expect(-> spy1.should.have.been.calledImmediatelyAfter(spy2)).to.not
.throw() |
| 125 |
| 126 it "should throw an assertion error when spy 1 is called after spy 2, bu
t not immediately", -> |
| 127 spy1() |
| 128 spy3() |
| 129 spy2() |
| 130 |
| 131 expect(-> spy1.should.have.been.calledImmediatelyAfter(spy2)).to.thr
ow(AssertionError) |
| 132 |
| OLD | NEW |