From 0fbaa2f12ab96328fe2e7b4b9f3ec0c8d7f30e37 Mon Sep 17 00:00:00 2001 From: Di Peng Date: Mon, 18 Jul 2011 15:31:14 -0700 Subject: feat(TzDate): add mock "toString" method to TzDate. - If the third param of TzDate constructor is defined, toStirng will just return this third parameter. Otherwise, toString will still be treated as unimplemented method --- test/angular-mocksSpec.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test/angular-mocksSpec.js') diff --git a/test/angular-mocksSpec.js b/test/angular-mocksSpec.js index 97949f63..b85503e6 100644 --- a/test/angular-mocksSpec.js +++ b/test/angular-mocksSpec.js @@ -121,6 +121,22 @@ describe('mocks', function(){ expect(date2.getUTCMinutes()).toBe(0); expect(date2.getUTCSeconds()).toBe(0); }); + + + it('should fake toString method when a third param is passed in', function() { + var t = new TzDate(0, 0, 'Mon Sep 3 2010 17:05:08 GMT+0500 (XYZ)'); + expect(t.toString()).toBe('Mon Sep 3 2010 17:05:08 GMT+0500 (XYZ)'); + }); + + + it('should throw error when no third param but toString called', function() { + var t = new TzDate(0, 0); + try { + t.toString(); + } catch(err) { + expect(err.name).toBe('MethodNotImplemented'); + } + }) }); describe('$log mock', function() { -- cgit v1.2.3