aboutsummaryrefslogtreecommitdiffstats
path: root/test/angular-mocks.js
diff options
context:
space:
mode:
authorMisko Hevery2010-09-14 22:51:01 +0200
committerMisko Hevery2010-09-14 22:51:01 +0200
commite3f760fbadedc977d9f5f461feafbaecab5a9046 (patch)
tree2d39d26b3b371649cfc6f0ababf055e50518f283 /test/angular-mocks.js
parent07699b1a70f2a979ecd600c826ba89e79279925c (diff)
downloadangular.js-e3f760fbadedc977d9f5f461feafbaecab5a9046.tar.bz2
Adding cookie service
- Browser.cookies() - MockBrowser - $cookie service - $sessionStore
Diffstat (limited to 'test/angular-mocks.js')
-rw-r--r--test/angular-mocks.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/angular-mocks.js b/test/angular-mocks.js
index bac2e800..1e547f77 100644
--- a/test/angular-mocks.js
+++ b/test/angular-mocks.js
@@ -26,6 +26,7 @@ function MockBrowser() {
var self = this,
expectations = {},
requests = [];
+
this.isMock = true;
self.url = "http://server";
self.watches = [];
@@ -72,6 +73,8 @@ function MockBrowser() {
requests.pop()();
}
};
+
+ self.cookieHash = {};
}
MockBrowser.prototype = {
@@ -90,11 +93,28 @@ MockBrowser.prototype = {
this.watches.push(fn);
},
+ watchCookies: function(fn) {
+ this.watches.push(fn);
+ },
+
fireUrlWatchers: function() {
for(var i=0; i<this.watches.length; i++) {
this.watches[i](this.url);
}
+ },
+
+ cookies: function(name, value) {
+ if (name) {
+ if (value == undefined) {
+ delete this.cookieHash[name];
+ } else {
+ this.cookieHash[name] = ""+value;
+ }
+ } else {
+ return copy(this.cookieHash);
+ }
}
+
};
angular.service('$browser', function(){