Permalink
Browse files

Better test for named parameters

  • Loading branch information...
1 parent 53f8f65 commit 7095675c6fb068dff636d4957da279bbe233ecd4 @tedeh committed Oct 7, 2013
Showing with 8 additions and 4 deletions.
  1. +0 −1 lib/server.js
  2. +8 −3 test/server.test.js
View
@@ -247,7 +247,6 @@ Server.prototype.call = function(request, originalCallback) {
// pop the last one out because it must be the callback
parameters.pop();
- // TODO deal with strictness (missing params etc)
args = parameters.map(function(name) {
return request.params[name];
});
View
@@ -175,7 +175,12 @@ describe('jayson server instance', function() {
describe('named parameters', function() {
var namedParamsRequest = utils.request('add', {b: 2, a: 9});
- it('should return the expected result', reqShouldBeResult(namedParamsRequest, 9 + 2));
+ it('should return as expected', reqShouldBeResult(namedParamsRequest, 9 + 2));
+
+ var wrongParamsRequest = utils.request('add', {});
+ it('should not fail when not given sufficient arguments', reqShouldBeResult(wrongParamsRequest, function(result) {
+ isNaN(result).should.be.true;
+ }));
});
@@ -288,8 +293,8 @@ describe('jayson server instance', function() {
should.not.exist(err);
should.exist(res);
should.exist(res.result);
- if(typeof(validate) === 'function') validate(res.result);
- else res.result.should.equal(validate);
+ if(typeof(validate) === 'function') return validate(res.result);
+ res.should.have.property('result', validate);
});
}

0 comments on commit 7095675

Please sign in to comment.