From 79b743e52feb2c57ba0ae42d6d2742bc2189b22f Mon Sep 17 00:00:00 2001 From: Adam Abrons Date: Mon, 15 Mar 2010 15:57:12 -0700 Subject: resources, with bind() --- test/ResourceSpec.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/ResourceSpec.js b/test/ResourceSpec.js index 562d6500..799c7378 100644 --- a/test/ResourceSpec.js +++ b/test/ResourceSpec.js @@ -62,7 +62,7 @@ describe("resource", function() { beforeEach(function(){ xhr = new MockXHR(); resource = new ResourceFactory(xhr); - CreditCard = resource.route('/CreditCard/:id:verb', {id:'id.key'}, { + CreditCard = resource.route('/CreditCard/:id:verb', {id:'@id.key'}, { charge:{ method:'POST', params:{verb:'!charge'} @@ -80,6 +80,15 @@ describe("resource", function() { expect(typeof CreditCard.query).toBe('function'); }); + 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(){ xhr.expectPOST('/CreditCard').data({name:'misko'}).respond({id:123, name:'misko'}); @@ -155,5 +164,12 @@ describe("resource", function() { expect(callback).wasCalledWith(cc); }); + it('should bind default parameters', function(){ + xhr.expectGET('/CreditCard/123.visa?minimum=0.05').respond({id:123}); + var Visa = CreditCard.bind({verb:'.visa', minimum:0.05}); + var visa = Visa.get({id:123}); + xhr.flush(); + nakedExpect(visa).toEqual({id:123}); + }); }); -- cgit v1.2.3