From 347be5ae9aa6829427e1e8e1b1e58afdf2a36c0a Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 13 Jan 2011 10:35:26 -0800 Subject: fixed select with ng:format select (one/multiple) could not chose from a list of objects, since DOM requires string ids. Solved by adding index formatter, which exposed incorrect handling of formatters in select widgets. --- test/JsonSpec.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'test/JsonSpec.js') diff --git a/test/JsonSpec.js b/test/JsonSpec.js index 6d8a40e4..4a160905 100644 --- a/test/JsonSpec.js +++ b/test/JsonSpec.js @@ -92,11 +92,11 @@ describe('json', function(){ it('should not serialize undefined values', function() { expect(angular.toJson({A:undefined})).toEqual('{}'); }); - + it('should not serialize $window object', function() { expect(toJson(window)).toEqual('WINDOW'); }); - + it('should not serialize $document object', function() { expect(toJson(document)).toEqual('DOCUMENT'); }); @@ -116,6 +116,13 @@ describe('json', function(){ expect(fromJson("{exp:1.2e-10}")).toEqual({exp:1.2E-10}); }); + it('should ignore non-strings', function(){ + expect(fromJson([])).toEqual([]); + expect(fromJson({})).toEqual({}); + expect(fromJson(null)).toEqual(null); + expect(fromJson(undefined)).toEqual(undefined); + }); + //run these tests only in browsers that have native JSON parser if (JSON && JSON.parse) { @@ -187,18 +194,18 @@ describe('json', function(){ expect(function(){fromJson('[].constructor');}). toThrow(new Error("Parse Error: Token '.' is not valid json at column 3 of expression [[].constructor] starting at [.constructor].")); }); - + it('should not allow object dereference', function(){ expect(function(){fromJson('{a:1, b: $location, c:1}');}).toThrow(); expect(function(){fromJson("{a:1, b:[1]['__parent__']['location'], c:1}");}).toThrow(); }); - + it('should not allow assignments', function(){ expect(function(){fromJson("{a:1, b:[1]=1, c:1}");}).toThrow(); expect(function(){fromJson("{a:1, b:=1, c:1}");}).toThrow(); expect(function(){fromJson("{a:1, b:x=1, c:1}");}).toThrow(); }); - + }); }); -- cgit v1.2.3