From aedf12f25e42877a302a99d906e6397bde01dcce Mon Sep 17 00:00:00 2001 From: Andres Ornelas Date: Wed, 26 May 2010 15:21:58 -0700 Subject: added outstanding request queue --- test/BrowserSpecs.js | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ test/BrowserTest.js | 25 ------------------------- 2 files changed, 48 insertions(+), 25 deletions(-) create mode 100644 test/BrowserSpecs.js delete mode 100644 test/BrowserTest.js (limited to 'test') diff --git a/test/BrowserSpecs.js b/test/BrowserSpecs.js new file mode 100644 index 00000000..3ce158b4 --- /dev/null +++ b/test/BrowserSpecs.js @@ -0,0 +1,48 @@ +describe('browser', function(){ + + var browser, location; + + beforeEach(function(){ + location = {href:"http://server", hash:""}; + browser = new Browser(location, {}); + browser.setTimeout = noop; + }); + + it('should watch url', function(){ + browser.delay = 1; + expectAsserts(2); + browser.watchUrl(function(url){ + assertEquals('http://getangular.test', url); + }); + browser.setTimeout = function(fn, delay){ + assertEquals(1, delay); + location.href = "http://getangular.test"; + browser.setTimeout = function(fn, delay) {}; + fn(); + }; + browser.startUrlWatcher(); + }); + + describe('outstading requests', function(){ + it('should process callbacks immedietly with no outstanding requests', function(){ + var callback = jasmine.createSpy('callback'); + browser.notifyWhenNoOutstandingRequests(callback); + expect(callback).wasCalled(); + }); + + it('should queue callbacks with outstanding requests', function(){ + var callback = jasmine.createSpy('callback'); + browser.outstandingRequests.count = 1; + browser.notifyWhenNoOutstandingRequests(callback); + expect(callback).not.wasCalled(); + + browser.processRequestCallbacks(); + expect(callback).not.wasCalled(); + + browser.outstandingRequests.count = 0; + browser.processRequestCallbacks(); + expect(callback).wasCalled(); + }); + }); + +}); diff --git a/test/BrowserTest.js b/test/BrowserTest.js deleted file mode 100644 index 5254840a..00000000 --- a/test/BrowserTest.js +++ /dev/null @@ -1,25 +0,0 @@ -BrowserTest = TestCase('BrowserTest'); - -BrowserTest.prototype.testUrlWatcher = function () { - expectAsserts(2); - var location = {href:"http://server", hash:""}; - var watcher = new Browser(location, {}); - watcher.delay = 1; - watcher.watchUrl(function(url){ - assertEquals('http://getangular.test', url); - }); - watcher.setTimeout = function(fn, delay){ - assertEquals(1, delay); - location.href = "http://getangular.test"; - watcher.setTimeout = function(fn, delay) { - }; - fn(); - }; - watcher.startUrlWatcher(); -}; - -FunctionTest = TestCase("FunctionTest"); - -FunctionTest.prototype.testEscapeHtml = function () { - assertEquals("<div>&amp;</div>", escapeHtml('
&
')); -}; -- cgit v1.2.3