From 4034a2d1e2efb6c76020273c96c3da5ae146f5ca Mon Sep 17 00:00:00 2001 From: Rob Spies Date: Tue, 13 Jul 2010 14:09:53 -0700 Subject: better naming for our verify cache scheme, and tests. --- test/ResourceSpec.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/ResourceSpec.js b/test/ResourceSpec.js index 4ab3537c..18b3979b 100644 --- a/test/ResourceSpec.js +++ b/test/ResourceSpec.js @@ -30,8 +30,7 @@ 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 LineItem = resource.route('/Order/:orderId/Line/:id:verb', {orderId: '123', id: '@id.key', verb:'.visa', minimum:0.05}, {verifyCache: 'blah'}); var item = LineItem.get({id:456}); xhr.flush(); nakedExpect(item).toEqual({id:'abc'}); @@ -136,6 +135,23 @@ describe("resource", function() { expect(person.name).toEqual('misko'); }); + it('should return the same object when verifying the cache', function(){ + var scope = angular.compile('
'); + var Person = scope.$resource('/Person/:id', null, {query: {method:'GET', isArray: true, verifyCache: true}}); + scope.$browser.xhr.expectGET('/Person/123').respond('[\n{\nname:\n"misko"\n}\n]'); + var person = Person.query({id:123}); + scope.$browser.xhr.flush(); + expect(person[0].name).toEqual('misko'); + + scope.$browser.xhr.expectGET('/Person/123').respond('[\n{\nname:\n"rob"\n}\n]'); + var person2 = Person.query({id:123}); + expect(person2[0].name).toEqual('misko'); + var person2Cache = person2; + scope.$browser.xhr.flush(); + expect(person2Cache).toEqual(person2); + expect(person2[0].name).toEqual('rob'); + }); + describe('failure mode', function(){ it('should report error when non 200', function(){ xhr.expectGET('/CreditCard/123').respond(500, "Server Error"); -- cgit v1.2.3