aboutsummaryrefslogtreecommitdiffstats
path: root/test/JsonSpec.js
diff options
context:
space:
mode:
authorMisko Hevery2011-01-13 10:35:26 -0800
committerMisko Hevery2011-01-14 10:30:00 -0800
commit347be5ae9aa6829427e1e8e1b1e58afdf2a36c0a (patch)
tree3b350a12378c1ec63f60cce0fe674186d204726e /test/JsonSpec.js
parent934f44f69e94a77a3ea6c19dc5c6f82ade2cc669 (diff)
downloadangular.js-347be5ae9aa6829427e1e8e1b1e58afdf2a36c0a.tar.bz2
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.
Diffstat (limited to 'test/JsonSpec.js')
-rw-r--r--test/JsonSpec.js17
1 files changed, 12 insertions, 5 deletions
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();
});
-
+
});
});