From 80e12276f423a0dcb486b1191857db96a0ba0a93 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Wed, 19 May 2010 13:24:20 -0700 Subject: added $log to console connection --- test/servicesSpec.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'test') diff --git a/test/servicesSpec.js b/test/servicesSpec.js index 60b465d2..45993490 100644 --- a/test/servicesSpec.js +++ b/test/servicesSpec.js @@ -31,6 +31,37 @@ describe("service", function(){ scope.$document.addStyleSheet('css/angular.css'); }); + describe("$log", function(){ + it('should use console if present', function(){ + function log(){}; + function warn(){}; + function info(){}; + function error(){}; + var scope = createScope(null, angularService, {$window: {console:{log:log, warn:warn, info:info, error:error}}}); + expect(scope.$log.log).toEqual(log); + expect(scope.$log.warn).toEqual(warn); + expect(scope.$log.info).toEqual(info); + expect(scope.$log.error).toEqual(error); + }); + + it('should use console.log if other not present', function(){ + function log(){}; + var scope = createScope(null, angularService, {$window: {console:{log:log}}}); + expect(scope.$log.log).toEqual(log); + expect(scope.$log.warn).toEqual(log); + expect(scope.$log.info).toEqual(log); + expect(scope.$log.error).toEqual(log); + }); + + it('should use noop if no console', function(){ + var scope = createScope(null, angularService, {$window: {}}); + expect(scope.$log.log).toEqual(noop); + expect(scope.$log.warn).toEqual(noop); + expect(scope.$log.info).toEqual(noop); + expect(scope.$log.error).toEqual(noop); + }); + }); + describe("$location", function(){ it("should inject $location", function(){ scope.$location.parse('http://host:123/p/a/t/h.html?query=value#path?key=value'); -- cgit v1.2.3 From 80bd0c273b20b6fde25bb38c7639821cd205f69b Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Wed, 19 May 2010 16:00:20 -0700 Subject: fixed isNumber to angular.isNumber for mocks outside of angular --- test/angular-mocks.js | 2 +- test/servicesSpec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/angular-mocks.js b/test/angular-mocks.js index c5784ac9..8838b2cd 100644 --- a/test/angular-mocks.js +++ b/test/angular-mocks.js @@ -54,7 +54,7 @@ function MockBrowser() { var expect = expectations[method] || (expectations[method] = {}); return { respond: function(code, response) { - if (!isNumber(code)) { + if (!angular.isNumber(code)) { response = code; code = 200; } diff --git a/test/servicesSpec.js b/test/servicesSpec.js index 45993490..c2c13461 100644 --- a/test/servicesSpec.js +++ b/test/servicesSpec.js @@ -288,7 +288,7 @@ describe("service", function(){ expect(typeof cb).toEqual('function'); expect($xhrError).wasCalledWith( {url:'/req1', method:'GET', data:null, callback:cb}, - {status:404, body:'NotFound'}); + {status:404, response:'NotFound'}); expect(log).toEqual('"second";DONE'); }); -- cgit v1.2.3