toJson should serialize inherited properties, but not any properties that start with $

This commit is contained in:
Igor Minar
2010-09-21 16:19:07 +02:00
parent 0d717310fd
commit 125d725e7d
2 changed files with 13 additions and 6 deletions

View File

@@ -74,11 +74,18 @@ JsonTest.prototype.testItShouldPreventRecursion = function () {
assertEquals('{"a":"b","recursion":RECURSION}', angular.toJson(obj));
};
JsonTest.prototype.testItShouldSerializeOnlyOwnProperties = function() {
var parent = createScope();
var child = createScope(parent);
child.c = 'c';
expect(angular.toJson(child)).toEqual('{"c":"c"}');
JsonTest.prototype.testItShouldIgnore$Properties = function() {
var scope = createScope();
scope.a = 'a';
scope['$b'] = '$b';
scope.c = 'c';
expect(angular.toJson(scope)).toEqual('{"a":"a","c":"c","this":RECURSION}');
};
JsonTest.prototype.testItShouldSerializeInheritedProperties = function() {
var scope = createScope({p:'p'});
scope.a = 'a';
expect(angular.toJson(scope)).toEqual('{"a":"a","p":"p","this":RECURSION}');
};
JsonTest.prototype.testItShouldSerializeSameObjectsMultipleTimes = function () {