From 35125d25137ac2da13ed1ca3e652ec8f2c945053 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Tue, 27 Mar 2012 12:44:37 -0700 Subject: refactor(toJson): use native JSON.stringify Instead of using our custom serializer we now use the native one and use the replacer function to customize the serialization to preserve most of the previous behavior (ignore $ and $$ properties as well as window, document and scope instances). --- src/ng/directive/input.js | 4 ++-- src/ng/filter/filters.js | 2 +- src/ng/filter/limitTo.js | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/ng') diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index 348c9f25..7343c358 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -671,7 +671,7 @@ function checkboxInputType(scope, element, attr, ctrl) { it('should initialize to model', function() { - expect(binding('user')).toEqual('{"last":"visitor","name":"guest"}'); + expect(binding('user')).toEqual('{"name":"guest","last":"visitor"}'); expect(binding('myForm.userName.$valid')).toEqual('true'); expect(binding('myForm.$valid')).toEqual('true'); }); @@ -685,7 +685,7 @@ function checkboxInputType(scope, element, attr, ctrl) { it('should be valid if empty when min length is set', function() { input('user.last').enter(''); - expect(binding('user')).toEqual('{"last":"","name":"guest"}'); + expect(binding('user')).toEqual('{"name":"guest","last":""}'); expect(binding('myForm.lastName.$valid')).toEqual('true'); expect(binding('myForm.$valid')).toEqual('true'); }); diff --git a/src/ng/filter/filters.js b/src/ng/filter/filters.js index c792cace..19f79ad1 100644 --- a/src/ng/filter/filters.js +++ b/src/ng/filter/filters.js @@ -407,7 +407,7 @@ function dateFilter($locale) { it('should jsonify filtered objects', function() { - expect(binding("{'name':'value'}")).toBe('{\n "name":"value"}'); + expect(binding("{'name':'value'}")).toMatch(/\{\n "name": ?"value"\n}/); }); diff --git a/src/ng/filter/limitTo.js b/src/ng/filter/limitTo.js index 4928fb9a..af94b2f4 100644 --- a/src/ng/filter/limitTo.js +++ b/src/ng/filter/limitTo.js @@ -31,24 +31,24 @@ }
- Limit {{numbers}} to: -

Output: {{ numbers | limitTo:limit | json }}

+ Limit {{numbers}} to: +

Output: {{ numbers | limitTo:limit }}

it('should limit the numer array to first three items', function() { expect(element('.doc-example-live input[ng-model=limit]').val()).toBe('3'); - expect(binding('numbers | limitTo:limit | json')).toEqual('[1,2,3]'); + expect(binding('numbers | limitTo:limit')).toEqual('[1,2,3]'); }); it('should update the output when -3 is entered', function() { input('limit').enter(-3); - expect(binding('numbers | limitTo:limit | json')).toEqual('[7,8,9]'); + expect(binding('numbers | limitTo:limit')).toEqual('[7,8,9]'); }); it('should not exceed the maximum size of input array', function() { input('limit').enter(100); - expect(binding('numbers | limitTo:limit | json')).toEqual('[1,2,3,4,5,6,7,8,9]'); + expect(binding('numbers | limitTo:limit')).toEqual('[1,2,3,4,5,6,7,8,9]'); }); -- cgit v1.2.3