aboutsummaryrefslogtreecommitdiffstats
path: root/test/ngCookies/cookiesSpec.js
diff options
context:
space:
mode:
authorCaitlin Potter2014-03-18 13:13:08 -0400
committerCaitlin Potter2014-03-18 22:50:17 -0400
commit3652831084c3788f786046b907a7361d2e89c520 (patch)
tree0f40157a58949b07715ee1bc2a0706bd9d0c0d57 /test/ngCookies/cookiesSpec.js
parentbc42950b514b60f319812eeb87aae2915e394237 (diff)
downloadangular.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/ngCookies/cookiesSpec.js')
-rw-r--r--test/ngCookies/cookiesSpec.js18
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'
+ });
}));