aboutsummaryrefslogtreecommitdiffstats
path: root/test/service/cookiesSpec.js
diff options
context:
space:
mode:
authorMisko Hevery2012-03-23 14:03:24 -0700
committerMisko Hevery2012-03-28 11:16:35 -0700
commit2430f52bb97fa9d682e5f028c977c5bf94c5ec38 (patch)
treee7529b741d70199f36d52090b430510bad07f233 /test/service/cookiesSpec.js
parent944098a4e0f753f06b40c73ca3e79991cec6c2e2 (diff)
downloadangular.js-2430f52bb97fa9d682e5f028c977c5bf94c5ec38.tar.bz2
chore(module): move files around in preparation for more modules
Diffstat (limited to 'test/service/cookiesSpec.js')
-rw-r--r--test/service/cookiesSpec.js97
1 files changed, 0 insertions, 97 deletions
diff --git a/test/service/cookiesSpec.js b/test/service/cookiesSpec.js
deleted file mode 100644
index 5427ac36..00000000
--- a/test/service/cookiesSpec.js
+++ /dev/null
@@ -1,97 +0,0 @@
-'use strict';
-
-describe('$cookies', function() {
- beforeEach(module(function($provide) {
- $provide.factory('$browser', function(){
- return angular.extend(new angular.mock.$Browser(), {cookieHash: {preexisting:'oldCookie'}});
- });
- }));
-
-
- it('should provide access to existing cookies via object properties and keep them in sync',
- inject(function($cookies, $browser, $rootScope) {
- expect($cookies).toEqual({'preexisting': 'oldCookie'});
-
- // access internal cookie storage of the browser mock directly to simulate behavior of
- // document.cookie
- $browser.cookieHash['brandNew'] = 'cookie';
- $browser.poll();
-
- expect($cookies).toEqual({'preexisting': 'oldCookie', 'brandNew':'cookie'});
-
- $browser.cookieHash['brandNew'] = 'cookie2';
- $browser.poll();
- expect($cookies).toEqual({'preexisting': 'oldCookie', 'brandNew':'cookie2'});
-
- delete $browser.cookieHash['brandNew'];
- $browser.poll();
- expect($cookies).toEqual({'preexisting': 'oldCookie'});
- }));
-
-
- it('should create or update a cookie when a value is assigned to a property',
- inject(function($cookies, $browser, $rootScope) {
- $cookies.oatmealCookie = 'nom nom';
- $rootScope.$digest();
-
- expect($browser.cookies()).
- toEqual({'preexisting': 'oldCookie', 'oatmealCookie':'nom nom'});
-
- $cookies.oatmealCookie = 'gone';
- $rootScope.$digest();
-
- expect($browser.cookies()).
- toEqual({'preexisting': 'oldCookie', 'oatmealCookie': 'gone'});
- }));
-
-
- it('should drop or reset any cookie that was set to a non-string value',
- inject(function($cookies, $browser, $rootScope) {
- $cookies.nonString = [1, 2, 3];
- $cookies.nullVal = null;
- $cookies.undefVal = undefined;
- $cookies.preexisting = function() {};
- $rootScope.$digest();
- expect($browser.cookies()).toEqual({'preexisting': 'oldCookie'});
- expect($cookies).toEqual({'preexisting': 'oldCookie'});
- }));
-
-
- it('should remove a cookie when a $cookies property is deleted',
- inject(function($cookies, $browser, $rootScope) {
- $cookies.oatmealCookie = 'nom nom';
- $rootScope.$digest();
- $browser.poll();
- expect($browser.cookies()).
- toEqual({'preexisting': 'oldCookie', 'oatmealCookie':'nom nom'});
-
- delete $cookies.oatmealCookie;
- $rootScope.$digest();
-
- expect($browser.cookies()).toEqual({'preexisting': 'oldCookie'});
- }));
-
-
- it('should drop or reset cookies that browser refused to store',
- inject(function($cookies, $browser, $rootScope) {
- var i, longVal;
-
- for (i=0; i<5000; i++) {
- longVal += '*';
- }
-
- //drop if no previous value
- $cookies.longCookie = longVal;
- $rootScope.$digest();
- expect($cookies).toEqual({'preexisting': 'oldCookie'});
-
-
- //reset if previous value existed
- $cookies.longCookie = 'shortVal';
- $rootScope.$digest();
- expect($cookies).toEqual({'preexisting': 'oldCookie', 'longCookie': 'shortVal'});
- $cookies.longCookie = longVal;
- $rootScope.$digest();
- expect($cookies).toEqual({'preexisting': 'oldCookie', 'longCookie': 'shortVal'});
- }));
-});