From 823ef738feb16fef2cc65cc1c9618207c089879d Mon Sep 17 00:00:00 2001 From: Ivan Tivonenko Date: Wed, 29 Jul 2015 17:40:59 +0300 Subject: [PATCH] cover api/common/utils.js with tests --- test/api-test.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/test/api-test.js b/test/api-test.js index e00be57e..83b2b6dd 100644 --- a/test/api-test.js +++ b/test/api-test.js @@ -12,7 +12,8 @@ const hashes = require('./fixtures/hashes'); const MockPRNG = require('./mock-prng'); const sjcl = require('../src').sjcl; const address = addresses.ACCOUNT; -const validate = require('../src/api/common/validate'); +const common = require('../src/api/common'); +const validate = common.validate; const RippleError = require('../src/core/rippleerror').RippleError; const utils = require('../src/api/ledger/utils'); const ledgerClosed = require('./fixtures/api/rippled/ledger-close-newer'); @@ -683,4 +684,26 @@ describe('RippleAPI', function() { }); + describe('common utils', function() { + + it('wrapCatch', function(done) { + common.wrapCatch(function() { + throw new Error('error'); + })(function(error) { + assert(error instanceof Error); + done(); + }); + }); + + it('convertExceptions', function() { + assert.throws(common.convertExceptions(function() { + throw new Error('fall through'); + }), this.api.errors.ApiError); + assert.throws(common.convertExceptions(function() { + throw new Error('fall through'); + }), /fall through/); + }); + + }); + });