From 42257f22af643fc5e91162cc99adeef32916fd28 Mon Sep 17 00:00:00 2001 From: Shyam Seshadri Date: Wed, 23 Jun 2010 13:07:31 -0700 Subject: wilford's changes to serve cached data and then fetch from server if needed / specified --- test/servicesSpec.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test') diff --git a/test/servicesSpec.js b/test/servicesSpec.js index c2c13461..f679a39b 100644 --- a/test/servicesSpec.js +++ b/test/servicesSpec.js @@ -306,12 +306,28 @@ describe("service", function(){ cache('GET', '/url', null, callback); xhr.flush(); expect(log).toEqual('"first";"first";'); + cache('GET', '/url', null, callback, false); + xhr.flush(); + expect(log).toEqual('"first";"first";"first";'); + }); + + it('should first return cache request, then return server request', function(){ + xhr.expectGET('/url').respond('first'); + cache('GET', '/url', null, callback, true); + xhr.flush(); + xhr.expectGET('/url').respond('ERROR'); + cache('GET', '/url', null, callback, true); + expect(log).toEqual('"first";"first";'); + xhr.flush(); + expect(log).toEqual('"first";"first";"ERROR";'); }); it('should serve requests from cache', function(){ cache.data.url = {value:'123'}; cache('GET', 'url', null, callback); expect(log).toEqual('"123";'); + cache('GET', 'url', null, callback, false); + expect(log).toEqual('"123";"123";'); }); it('should keep track of in flight requests and request only once', function(){ -- cgit v1.2.3