diff options
| author | Alkis Evlogimenos | 2010-09-15 19:27:58 +0200 |
|---|---|---|
| committer | Misko Hevery | 2010-09-16 00:23:22 +0200 |
| commit | 293f34cd64886a1dddae9c295fafde5c47029a3b (patch) | |
| tree | b1cb99e8be24eb23d39ac8aee45d531e3ee96704 /test/ResourceSpec.js | |
| parent | b798ee80c29d877aa8c9934382a140a080fa13bc (diff) | |
| download | angular.js-293f34cd64886a1dddae9c295fafde5c47029a3b.tar.bz2 | |
Expose GET operations on resources as well. This allows us to read
"partials". The pattern is demostrated in the unittest:
Resource.query returns a list of "keys" to resources, which are
partially defined. They have enough data to allow $get to fetch the
whole gamout. Then $get fetches all the details of the resource.
Diffstat (limited to 'test/ResourceSpec.js')
| -rw-r--r-- | test/ResourceSpec.js | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/test/ResourceSpec.js b/test/ResourceSpec.js index 1ac43d74..435176b0 100644 --- a/test/ResourceSpec.js +++ b/test/ResourceSpec.js @@ -70,6 +70,21 @@ describe("resource", function() { expect(callback).wasCalledWith(cc); }); + it("should read partial resource", function(){ + xhr.expectGET("/CreditCard").respond([{id:{key:123}}]); + xhr.expectGET("/CreditCard/123").respond({id:{key:123}, number:'9876'}); + var ccs = CreditCard.query(); + xhr.flush(); + expect(ccs.length).toEqual(1); + var cc = ccs[0]; + expect(cc instanceof CreditCard).toBeTruthy(); + expect(cc.number).not.toBeDefined(); + cc.$get(callback); + xhr.flush(); + expect(callback).wasCalledWith(cc); + expect(cc.number).toEqual('9876'); + }); + it("should update resource", function(){ xhr.expectPOST('/CreditCard/123', {id:{key:123}, name:'misko'}).respond({id:{key:123}, name:'rama'}); @@ -124,8 +139,8 @@ describe("resource", function() { it('should create on save', function(){ xhr.expectPOST('/CreditCard', {name:'misko'}).respond({id:123}); var cc = new CreditCard(); - expect(cc.$get).not.toBeDefined(); - expect(cc.$query).not.toBeDefined(); + expect(cc.$get).toBeDefined(); + expect(cc.$query).toBeDefined(); expect(cc.$remove).toBeDefined(); expect(cc.$save).toBeDefined(); |
