From 125d725e7dcd76b838925ac997b35afad4266752 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Tue, 21 Sep 2010 16:19:07 +0200 Subject: toJson should serialize inherited properties, but not any properties that start with $ --- test/JsonTest.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/JsonTest.js b/test/JsonTest.js index f6da26b5..c723121f 100644 --- a/test/JsonTest.js +++ b/test/JsonTest.js @@ -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 () { -- cgit v1.2.3