diff options
| author | Andres Ornelas | 2010-05-26 15:21:58 -0700 | 
|---|---|---|
| committer | Andres Ornelas | 2010-05-26 15:21:58 -0700 | 
| commit | aedf12f25e42877a302a99d906e6397bde01dcce (patch) | |
| tree | fd6ac4fe05668128937261093752b36c1bb02a6a /test/BrowserSpecs.js | |
| parent | 0d41c86522ef912fe5bb7a02fd434080f9827c00 (diff) | |
| download | angular.js-aedf12f25e42877a302a99d906e6397bde01dcce.tar.bz2 | |
added outstanding request queue
Diffstat (limited to 'test/BrowserSpecs.js')
| -rw-r--r-- | test/BrowserSpecs.js | 48 | 
1 files changed, 48 insertions, 0 deletions
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(); +    }); +  }); + +});  | 
