Skip to content

Commit

Permalink
Better test for named parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
tedeh committed Oct 7, 2013
1 parent 53f8f65 commit 7095675
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 0 additions & 1 deletion lib/server.js
Expand Up @@ -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];
});
Expand Down
11 changes: 8 additions & 3 deletions test/server.test.js
Expand Up @@ -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;
}));

});

Expand Down Expand Up @@ -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);
});
}

Expand Down

0 comments on commit 7095675

Please sign in to comment.