From 9798f5e35fd150c319004c953ed627b5b28dad71 Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Fri, 4 Feb 2011 01:32:55 +0000 Subject: mock $log: fixed bug, added some tests I extracted mock $log factory into stand alone function, so we can access it and test, because this service is rewritten by real service during testing, so we can't access it through angular.$service('$log')... --- test/angular-mocksSpec.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'test') diff --git a/test/angular-mocksSpec.js b/test/angular-mocksSpec.js index b96a9cfc..fabc47ea 100644 --- a/test/angular-mocksSpec.js +++ b/test/angular-mocksSpec.js @@ -119,3 +119,46 @@ describe('TzDate', function() { expect(date2.getUTCSeconds()).toBe(0); }); }); + +describe('$log', function() { + var $log; + beforeEach(function() { + $log = MockLogFactory(); + }); + + it('should provide log method', function() { + expect(function() { $log.log(''); }).not.toThrow(); + }); + + it('should provide info method', function() { + expect(function() { $log.info(''); }).not.toThrow(); + }); + + it('should provide warn method', function() { + expect(function() { $log.warn(''); }).not.toThrow(); + }); + + it('should provide error method', function() { + expect(function() { $log.error(''); }).not.toThrow(); + }); + + it('should store log messages', function() { + $log.log('fake log'); + expect($log.log.logs).toContain(['fake log']); + }); + + it('should store info messages', function() { + $log.info('fake log'); + expect($log.info.logs).toContain(['fake log']); + }); + + it('should store warn messages', function() { + $log.warn('fake log'); + expect($log.warn.logs).toContain(['fake log']); + }); + + it('should store error messages', function() { + $log.error('fake log'); + expect($log.error.logs).toContain(['fake log']); + }); +}); -- cgit v1.2.3