diff --git a/test/expect-0.2.0-ol3/expect.js b/test/expect-0.2.0-ol3/expect.js index 24fc5d7437..5d2d57b184 100644 --- a/test/expect-0.2.0-ol3/expect.js +++ b/test/expect-0.2.0-ol3/expect.js @@ -477,6 +477,21 @@ return this; }; + + /** + * Assert that a sinon spy was called. + * + * @api public + */ + Assertion.prototype.called = + Assertion.prototype.totallyWantsToSpeakToYou = function() { + this.assert( + this.obj.called + , function(){ return 'expected ' + i(this.obj) + ' to be called' } + , function(){ return 'expected ' + i(this.obj) + ' not to be called' }); + return this; + }; + /** * Assert a failure. * diff --git a/test/spec/ol/expect.test.js b/test/spec/ol/expect.test.js index 8c71af21c8..e3f1cab072 100644 --- a/test/spec/ol/expect.test.js +++ b/test/spec/ol/expect.test.js @@ -40,4 +40,53 @@ describe('expect.js', function() { }); + describe('called', function() { + + var telephone; + beforeEach(function() { + telephone = sinon.spy(); + }); + + it('has caller ID', function() { + telephone(); + expect(telephone).to.be.called(); + }); + + it('also knows when it\'s speaking to the hand', function() { + (function() {})(); + expect(telephone).not.to.be.called(); + }); + + }); + + describe('totallyWantsToSpeakToYou', function() { + + var callMeMaybe; + beforeEach(function() { + callMeMaybe = sinon.spy(); + }); + + it('reminds you that you forgot', function() { + expect(function() { + expect(callMeMaybe).to.be.called(); + }).to.throwException(); + }); + + it('gets moody all too quickly', function() { + callMeMaybe(); + expect(function() { + expect(callMeMaybe).not.to.be.called(); + }).to.throwException(); + }); + + }); + + describe('called and totallyWantsToSpeakToYou', function() { + + it('are best friends forever \u2665', function() { + expect(expect(0).to.called).to.be(expect(1).to.totallyWantsToSpeakToYou); + }); + + }); + }); diff --git a/test/test-extensions.js b/test/test-extensions.js index eeec0751ff..22c3cab3a5 100644 --- a/test/test-extensions.js +++ b/test/test-extensions.js @@ -24,11 +24,6 @@ expect.Assertion.prototype.intersectWith = function(other) { }; -expect.Assertion.prototype.called = function() { - return this.obj.called; -}; - - expect.Assertion.prototype.equalArray = function(other) { return goog.array.equals(this.obj, other); };