From 0649009624e8e7bd6fb39537f62c6f00facbfb16 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Wed, 22 Sep 2010 13:24:40 +0200 Subject: 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 --- test/angular-mocks.js | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'test/angular-mocks.js') 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