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/JsonSpec.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/JsonSpec.js')
| -rw-r--r-- | test/JsonSpec.js | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/test/JsonSpec.js b/test/JsonSpec.js index 0acbd79c..f0019bef 100644 --- a/test/JsonSpec.js +++ b/test/JsonSpec.js @@ -74,7 +74,7 @@ describe('json', function(){ }); it('should serialize $ properties', function() { - var obj = {$a: 'a'} + var obj = {$a: 'a'}; expect(angular.toJson(obj)).toEqual('{"$a":"a"}'); }); @@ -118,31 +118,38 @@ describe('json', function(){ describe('security', function(){ it('should not allow naked expressions', function(){ - expect(function(){fromJson('1+2');}).toThrow("Did not understand '+2' while evaluating '1+2'."); + expect(function(){fromJson('1+2');}). + toThrow(new Error("Parse Error: Token '+' is extra token not part of expression at column 2 of expression [1+2] starting at [+2].")); }); it('should not allow naked expressions group', function(){ - expect(function(){fromJson('(1+2)');}).toThrow("Expression at column='0' of expression '(1+2)' starting at '(1+2)' is not valid json."); + expect(function(){fromJson('(1+2)');}). + toThrow(new Error("Parse Error: Token '(' is not valid json at column 1 of expression [(1+2)] starting at [(1+2)].")); }); it('should not allow expressions in objects', function(){ - expect(function(){fromJson('{a:abc()}');}).toThrow("Expression at column='3' of expression '{a:abc()}' starting at 'abc()}' is not valid json."); + expect(function(){fromJson('{a:abc()}');}). + toThrow(new Error("Parse Error: Token 'abc' is not valid json at column 4 of expression [{a:abc()}] starting at [abc()}].")); }); it('should not allow expressions in arrays', function(){ - expect(function(){fromJson('[1+2]');}).toThrow("Expression at column='2' of expression '[1+2]' starting at '+2]' is not valid json."); + expect(function(){fromJson('[1+2]');}). + toThrow(new Error("Parse Error: Token '+' is not valid json at column 3 of expression [[1+2]] starting at [+2]].")); }); it('should not allow vars', function(){ - expect(function(){fromJson('[1, x]');}).toThrow("Expression at column='4' of expression '[1, x]' starting at 'x]' is not valid json."); + expect(function(){fromJson('[1, x]');}). + toThrow(new Error("Parse Error: Token 'x' is not valid json at column 5 of expression [[1, x]] starting at [x]].")); }); it('should not allow dereference', function(){ - expect(function(){fromJson('["".constructor]');}).toThrow("Expression at column='3' of expression '[\"\".constructor]' starting at '.constructor]' is not valid json."); + expect(function(){fromJson('["".constructor]');}). + toThrow(new Error("Parse Error: Token '.' is not valid json at column 4 of expression [[\"\".constructor]] starting at [.constructor]].")); }); it('should not allow expressions ofter valid json', function(){ - expect(function(){fromJson('[].constructor');}).toThrow("Expression at column='2' of expression '[].constructor' starting at '.constructor' is not valid json."); + expect(function(){fromJson('[].constructor');}). + toThrow(new Error("Parse Error: Token '.' is not valid json at column 3 of expression [[].constructor] starting at [.constructor].")); }); }); |
