aboutsummaryrefslogtreecommitdiffstats
path: root/test/servicesSpec.js
diff options
context:
space:
mode:
authorShyam Seshadri2010-06-23 13:07:31 -0700
committerShyam Seshadri2010-06-23 13:07:31 -0700
commit42257f22af643fc5e91162cc99adeef32916fd28 (patch)
tree85f78cf493e79a44fc02d4749da681296d83dcea /test/servicesSpec.js
parent70c3dc81665191cd065a5303e5e26639a0023a73 (diff)
downloadangular.js-42257f22af643fc5e91162cc99adeef32916fd28.tar.bz2
wilford's changes to serve cached data and then fetch from server if needed / specified
Diffstat (limited to 'test/servicesSpec.js')
-rw-r--r--test/servicesSpec.js16
1 files changed, 16 insertions, 0 deletions
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(){