Merge pull request #758 from eordano/fix/precondArgument

Fix #756: Preconditions Invalid Argument
This commit is contained in:
Manuel Aráoz 2014-12-16 15:41:07 -03:00
commit e39543b730
2 changed files with 16 additions and 1 deletions

View File

@ -27,7 +27,7 @@ module.exports = [{
message: format('Invalid network: must be "livenet" or "testnet", got {0}')
}, {
name: 'InvalidArgument',
message: format('Invalid Argument {0}, {1}')
message: format('Invalid Argument' + '\' + (arguments[0] ? \': {0}\' : \'\') + \'')
}, {
name: 'AbstractMethodInvoked',
message: format('Abstract Method Invokation: {0}')

View File

@ -61,4 +61,19 @@ describe('preconditions', function() {
$.checkArgumentType(new PrivateKey(), PrivateKey);
}).should.not.throw();
});
it('formats correctly a message on InvalidArgument()', function() {
var error = new errors.InvalidArgument();
error.message.should.equal('Invalid Argument');
});
it('formats correctly a message on checkArgument', function() {
var error;
try {
$.checkArgument(null, 'parameter must be provided');
} catch (e) {
error = e;
}
error.message.should.equal('Invalid Argument: parameter must be provided');
});
});