diff options
| author | Misko Hevery | 2010-11-16 13:57:41 -0800 |
|---|---|---|
| committer | Igor Minar | 2010-11-16 14:19:55 -0800 |
| commit | b2d63ac48bdc61b5a4afdd10b8485c0c1ab8cdca (patch) | |
| tree | 0b798ba07d5b593dcc3e27964e81eb0542440d56 /test/servicesSpec.js | |
| parent | 4af32de84a264e05eebfa6dbc09ce10fac1e1417 (diff) | |
| download | angular.js-b2d63ac48bdc61b5a4afdd10b8485c0c1ab8cdca.tar.bz2 | |
Changed error handling so that better stack traces are displayed in the ng-errors
Diffstat (limited to 'test/servicesSpec.js')
| -rw-r--r-- | test/servicesSpec.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/servicesSpec.js b/test/servicesSpec.js index f4d9aabe..13e61b18 100644 --- a/test/servicesSpec.js +++ b/test/servicesSpec.js @@ -70,6 +70,42 @@ describe("service", function(){ scope.$log.info(); scope.$log.error(); }); + + describe('Error', function(){ + var e, $log, $console, errorArgs; + beforeEach(function(){ + e = new Error(''); + e.message = undefined; + e.sourceURL = undefined; + e.line = undefined; + e.stack = undefined; + + $console = angular.service('$log')({console:{error:function(){ + errorArgs = arguments; + }}}); + }); + + it('should pass error if does not have trace', function(){ + $console.error('abc', e); + expect(errorArgs).toEqual(['abc', e]); + }); + + it('should print stack', function(){ + e.stack = 'stack'; + $console.error('abc', e); + expect(errorArgs).toEqual(['abc', 'stack']); + }); + + it('should print line', function(){ + e.message = 'message'; + e.sourceURL = 'sourceURL'; + e.line = '123'; + $console.error('abc', e); + expect(errorArgs).toEqual(['abc', 'message\nsourceURL:123']); + }); + + }); + }); describe("$exceptionHandler", function(){ |
