aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/ResourceSpec.js7
-rw-r--r--test/servicesSpec.js16
2 files changed, 21 insertions, 2 deletions
diff --git a/test/ResourceSpec.js b/test/ResourceSpec.js
index 2f285bcf..d11c3e08 100644
--- a/test/ResourceSpec.js
+++ b/test/ResourceSpec.js
@@ -30,11 +30,16 @@ describe("resource", function() {
it("should build resource with default param", function(){
xhr.expectGET('/Order/123/Line/456.visa?minimum=0.05').respond({id:'abc'});
+ xhr.expectGET('/Order/123/Line/456.visa?minimum=0.05').respond({id:'ddd'});
var LineItem = resource.route('/Order/:orderId/Line/:id:verb', {orderId: '123', id: '@id.key', verb:'.visa', minimum:0.05});
var item = LineItem.get({id:456});
xhr.flush();
nakedExpect(item).toEqual({id:'abc'});
+ item = LineItem.get({id:456});
+ xhr.flush();
+ nakedExpect(item).toEqual({id:'abc'});
+
});
it("should create resource", function(){
@@ -66,8 +71,6 @@ describe("resource", function() {
nakedExpect(cc).toEqual({id:{key:123}, name:'misko'});
expect(callback).wasNotCalled();
xhr.flush();
- nakedExpect(cc).toEqual({id:{key:123}, name:'rama'});
- expect(callback).wasCalledWith(cc);
});
it("should query resource", function(){
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(){