diff options
Diffstat (limited to 'test/ResourceSpec.js')
| -rw-r--r-- | test/ResourceSpec.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/ResourceSpec.js b/test/ResourceSpec.js index 4882e70e..546e9aec 100644 --- a/test/ResourceSpec.js +++ b/test/ResourceSpec.js @@ -28,6 +28,18 @@ 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}); @@ -102,6 +114,13 @@ describe("resource", function() { CreditCard.charge({id:123, amount:10},{auth:'abc'}, callback); }); + it('should post charge verb on instance', function(){ + xhr.expectPOST('/CreditCard/123!charge?amount=10', {id:{key:123}, name:'misko'}).respond({success:'ok'}); + + var card = new CreditCard({id:{key:123}, name:'misko'}); + card.$charge({amount:10}, callback); + }); + it('should create on save', function(){ xhr.expectPOST('/CreditCard', {name:'misko'}).respond({id:123}); var cc = new CreditCard(); |
