From a34077a8afa7ddf56158a60c01ee8d7da0bcb7f4 Mon Sep 17 00:00:00 2001 From: Gunnar Ahlberg Date: Wed, 2 May 2012 14:11:22 +0200 Subject: [PATCH] cover spy on on undefined method --- spec/core/SpySpec.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/core/SpySpec.js b/spec/core/SpySpec.js index 05239172..90439c4e 100644 --- a/spec/core/SpySpec.js +++ b/spec/core/SpySpec.js @@ -165,6 +165,21 @@ describe('Spies', function () { expect(exception).toBeDefined(); }); + + it('to spy on an undefined method throws exception', function() { + var TestClass = { + someFunction : function() { + } + }; + function efunc() { + this.spyOn(TestClass, 'someOtherFunction'); + }; + expect(function() { + efunc(); + }).toThrow('someOtherFunction() method does not exist'); + + }); + it('should be able to reset a spy', function() { var TestClass = { someFunction: function() {} }; this.spyOn(TestClass, 'someFunction');