diff options
| author | Andres Ornelas | 2010-07-27 10:44:46 -0700 |
|---|---|---|
| committer | Andres Ornelas | 2010-07-27 10:44:46 -0700 |
| commit | b42072733c3afd03a49457d88ffed28ebe55655e (patch) | |
| tree | 2fa2b8703cdc75fe19a204d2c9677e27d33c8176 /test/servicesSpec.js | |
| parent | 2f7c538628929888ce7c99b9577e34f8c87211f7 (diff) | |
| parent | 8ddee9bb25ade2bbe7d57db6353b29867606c184 (diff) | |
| download | angular.js-b42072733c3afd03a49457d88ffed28ebe55655e.tar.bz2 | |
Merge branch 'master' of github.com:angular/angular.js into future
Diffstat (limited to 'test/servicesSpec.js')
| -rw-r--r-- | test/servicesSpec.js | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/test/servicesSpec.js b/test/servicesSpec.js index f679a39b..91538703 100644 --- a/test/servicesSpec.js +++ b/test/servicesSpec.js @@ -1,5 +1,5 @@ describe("service", function(){ - var scope, $xhrError, $log; + var scope, $xhrError, $log, mockServices; beforeEach(function(){ $xhrError = jasmine.createSpy('$xhr.error'); @@ -33,32 +33,45 @@ describe("service", function(){ 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); + var logger = ""; + function log(){ logger+= 'log;'; }; + function warn(){ logger+= 'warn;'; }; + function info(){ logger+= 'info;'; }; + function error(){ logger+= 'error;'; }; + var scope = createScope(null, angularService, {$window: {console:{log:log, warn:warn, info:info, error:error}}, $document:[{}]}); + scope.$log.log(); + scope.$log.warn(); + scope.$log.info(); + scope.$log.error(); + expect(logger).toEqual('log;warn;info;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); + var logger = ""; + function log(){ logger+= 'log;'; }; + var scope = createScope(null, angularService, {$window: {console:{log:log}}, $document:[{}]}); + scope.$log.log(); + scope.$log.warn(); + scope.$log.info(); + scope.$log.error(); + expect(logger).toEqual('log;log;log;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); + var scope = createScope(null, angularService, {$window: {}, $document:[{}]}); + scope.$log.log(); + scope.$log.warn(); + scope.$log.info(); + scope.$log.error(); + }); + }); + + describe("$exceptionHandler", function(){ + it('should log errors', function(){ + var error = ''; + $log.error = function(m) { error += m; }; + scope.$exceptionHandler('myError'); + expect(error).toEqual('myError'); }); }); @@ -136,7 +149,7 @@ describe("service", function(){ describe("$invalidWidgets", function(){ it("should count number of invalid widgets", function(){ - var scope = compile('<input name="price" ng-required ng-validate="number"></input>').$init(); + var scope = compile('<input name="price" ng:required ng:validate="number"></input>').$init(); expect(scope.$invalidWidgets.length).toEqual(1); scope.price = 123; scope.$eval(); |
