diff options
| author | Andres Ornelas | 2010-07-27 10:44:46 -0700 |
|---|---|---|
| committer | Andres Ornelas | 2010-07-27 10:44:46 -0700 |
| commit | b42072733c3afd03a49457d88ffed28ebe55655e (patch) | |
| tree | 2fa2b8703cdc75fe19a204d2c9677e27d33c8176 /test/ResourceSpec.js | |
| parent | 2f7c538628929888ce7c99b9577e34f8c87211f7 (diff) | |
| parent | 8ddee9bb25ade2bbe7d57db6353b29867606c184 (diff) | |
| download | angular.js-b42072733c3afd03a49457d88ffed28ebe55655e.tar.bz2 | |
Merge branch 'master' of github.com:angular/angular.js into future
Diffstat (limited to 'test/ResourceSpec.js')
| -rw-r--r-- | test/ResourceSpec.js | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/test/ResourceSpec.js b/test/ResourceSpec.js index 2f285bcf..6e32ce18 100644 --- a/test/ResourceSpec.js +++ b/test/ResourceSpec.js @@ -28,13 +28,24 @@ describe("resource", function() { resource.route('URL').query(); }); + it('should ignore slashes of undefinend parameters', function(){ + var R = resource.route('/Path/:a/:b/:c'); + xhr.expectGET('/Path').respond({}); + xhr.expectGET('/Path/1').respond({}); + xhr.expectGET('/Path/2/3').respond({}); + xhr.expectGET('/Path/4/5/6').respond({}); + R.get({}); + R.get({a:1}); + R.get({a:2, b:3}); + R.get({a:4, b:5, c:6}); + }); + it("should build resource with default param", function(){ xhr.expectGET('/Order/123/Line/456.visa?minimum=0.05').respond({id:'abc'}); 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'}); - }); it("should create resource", function(){ @@ -66,8 +77,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(){ @@ -138,6 +147,23 @@ describe("resource", function() { expect(person.name).toEqual('misko'); }); + it('should return the same object when verifying the cache', function(){ + var scope = angular.compile('<div></div>'); + 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"); |
