diff options
| author | Caitlin Potter | 2014-03-18 13:13:08 -0400 | 
|---|---|---|
| committer | Caitlin Potter | 2014-03-18 22:50:17 -0400 | 
| commit | 3652831084c3788f786046b907a7361d2e89c520 (patch) | |
| tree | 0f40157a58949b07715ee1bc2a0706bd9d0c0d57 /test | |
| parent | bc42950b514b60f319812eeb87aae2915e394237 (diff) | |
| download | angular.js-3652831084c3788f786046b907a7361d2e89c520.tar.bz2 | |
fix(ngCookie): convert non-string values to string
Previously, non-string values stored in $cookies would be removed, without warning the user, and
causing difficulty debugging. Now, the value is converted to string before being stored, and the
value is not dropped. Serialization may be customized using the toString() method of an object's
prototype.
Closes #6151
Closes #6220
Diffstat (limited to 'test')
| -rw-r--r-- | test/ngCookies/cookiesSpec.js | 18 | 
1 files changed, 14 insertions, 4 deletions
| diff --git a/test/ngCookies/cookiesSpec.js b/test/ngCookies/cookiesSpec.js index 674c2774..1d669c1c 100644 --- a/test/ngCookies/cookiesSpec.js +++ b/test/ngCookies/cookiesSpec.js @@ -45,15 +45,25 @@ describe('$cookies', function() {    })); -  it('should drop or reset any cookie that was set to a non-string value', +  it('should convert non-string values to string',        inject(function($cookies, $browser, $rootScope) {      $cookies.nonString = [1, 2, 3];      $cookies.nullVal = null;      $cookies.undefVal = undefined; -    $cookies.preexisting = function() {}; +    var preexisting = $cookies.preexisting = function() {};      $rootScope.$digest(); -    expect($browser.cookies()).toEqual({'preexisting': 'oldCookie'}); -    expect($cookies).toEqual({'preexisting': 'oldCookie'}); +    expect($browser.cookies()).toEqual({ +      'preexisting': '' + preexisting, +      'nonString': '1,2,3', +      'nullVal': 'null', +      'undefVal': 'undefined' +    }); +    expect($cookies).toEqual({ +      'preexisting': '' + preexisting, +      'nonString': '1,2,3', +      'nullVal': 'null', +      'undefVal': 'undefined' +    });    })); | 
