cover api/common/errors.js with tests

This commit is contained in:
Ivan Tivonenko
2015-07-29 18:10:41 +03:00
parent 823ef738fe
commit 63e3b71eb5
6 changed files with 35 additions and 5 deletions

View File

@@ -208,11 +208,11 @@ describe('RippleAPI', function() {
'getTransaction', done));
});
it('getTransaction - trustline froze off', function(done) {
it('getTransaction - trustline frozen off', function(done) {
const hash =
'FE72FAD0FA7CA904FB6C633A1666EDF0B9C73B2F5A4555D37EEF2739A78A531B';
this.api.getTransaction(hash, {},
_.partial(checkResult, responses.getTransaction.trustlineFrozeOff,
_.partial(checkResult, responses.getTransaction.trustlineFrozenOff,
'getTransaction', done));
});
@@ -706,4 +706,34 @@ describe('RippleAPI', function() {
});
describe('common errors', function() {
it('TransactionError', function() {
// TransactionError is not used anywhere, so just test its creation
assert.throws(function() {
throw new common.errors.TransactionError('fall through');
}, this.api.errors.TransactionError);
assert.throws(function() {
throw new common.errors.TransactionError('fall through');
}, /fall through/);
});
it('TimeOutError', function() {
// TimeOutError is not used anywhere, so just test its creation
assert.throws(function() {
throw new common.errors.TimeOutError('fall through');
}, this.api.errors.TimeOutError);
assert.throws(function() {
throw new common.errors.TimeOutError('fall through');
}, /fall through/);
});
it('RippledNetworkError', function() {
assert.throws(function() {
throw new common.errors.RippledNetworkError();
}, /Cannot connect to rippled/);
});
});
});

View File

@@ -22,7 +22,7 @@ module.exports = {
trackingOn: require('./get-transaction-settings-tracking-on.json'),
trackingOff: require('./get-transaction-settings-tracking-off.json'),
setRegularKey: require('./get-transaction-settings-set-regular-key.json'),
trustlineFrozeOff: require('./get-transaction-trust-set-froze-off.json'),
trustlineFrozenOff: require('./get-transaction-trust-set-frozen-off.json'),
notValidated: require('./get-transaction-not-validated.json')
},
getTransactions: require('./get-transactions.json'),

View File

@@ -30,7 +30,7 @@ module.exports = {
OfferCreate: require('./tx/offer-create.json'),
OfferCancel: require('./tx/offer-cancel.json'),
TrustSet: require('./tx/trust-set.json'),
TrustSetFrozeOff: require('./tx/trust-set-froze-off.json'),
TrustSetFrozenOff: require('./tx/trust-set-frozen-off.json'),
NotFound: require('./tx/not-found.json'),
NoLedgerIndex: require('./tx/no-ledger-index.json'),
NoLedgerFound: require('./tx/no-ledger-found.json'),

View File

@@ -160,7 +160,7 @@ module.exports = function(port) {
conn.send(createResponse(request, fixtures.tx.LedgerWithoutTime));
} else if (request.transaction ===
'FE72FAD0FA7CA904FB6C633A1666EDF0B9C73B2F5A4555D37EEF2739A78A531B') {
conn.send(createResponse(request, fixtures.tx.TrustSetFrozeOff));
conn.send(createResponse(request, fixtures.tx.TrustSetFrozenOff));
} else if (request.transaction ===
'4FB3ADF22F3C605E23FAEFAA185F3BD763C4692CAC490D9819D117CD33BFAA10') {
conn.send(createResponse(request, fixtures.tx.NotValidated));