aboutsummaryrefslogtreecommitdiffstats
path: root/test/angular-mocks.js
diff options
context:
space:
mode:
authorMisko Hevery2010-09-22 13:24:40 +0200
committerMisko Hevery2010-09-22 16:17:44 +0200
commit0649009624e8e7bd6fb39537f62c6f00facbfb16 (patch)
treee85077e148220ce75926bffce2d1e7daf8069945 /test/angular-mocks.js
parenteefb920d0e0345485a8eb120aeecc3b1aa9f6719 (diff)
downloadangular.js-0649009624e8e7bd6fb39537f62c6f00facbfb16.tar.bz2
Refactored the Browser:
- change from using prototype to inner functions to help with better compression - removed watchers (url/cookie) and introduced a poller concept - moved the checking of URL and cookie into services which register with poolers Benefits: - Smaller minified file - can call $browser.poll() from tests to simulate polling - single place where setTimeout needs to be tested - More testable $browser
Diffstat (limited to 'test/angular-mocks.js')
-rw-r--r--test/angular-mocks.js24
1 files changed, 9 insertions, 15 deletions
diff --git a/test/angular-mocks.js b/test/angular-mocks.js
index 1e547f77..a0d25042 100644
--- a/test/angular-mocks.js
+++ b/test/angular-mocks.js
@@ -29,7 +29,7 @@ function MockBrowser() {
this.isMock = true;
self.url = "http://server";
- self.watches = [];
+ self.pollFns = [];
self.xhr = function(method, url, data, callback) {
if (angular.isFunction(data)) {
@@ -78,6 +78,14 @@ function MockBrowser() {
}
MockBrowser.prototype = {
+ poll: function poll(){
+ foreach(this.pollFns, function(pollFn){ pollFn(); });
+ },
+
+ addPollFn: function(pollFn) {
+ this.pollFns.push(pollFn);
+ },
+
hover: function(onHover) {
},
@@ -89,20 +97,6 @@ MockBrowser.prototype = {
this.url = url;
},
- watchUrl: function(fn) {
- 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) {