test(plugins): plugin load + configure tests added

This commit is contained in:
Damian Mee 2014-08-21 04:10:13 +02:00
parent f97fda585f
commit edffd2f595
11 changed files with 509 additions and 267 deletions

View file

@ -1,54 +1,54 @@
'use strict';
// 'use strict';
var assert = require('chai').assert;
var Trader = require('../../lib/trader.js');
var PostgresqlInterface = require('../../lib/postgresql_interface.js');
// var assert = require('chai').assert;
// var Trader = require('../../lib/trader.js');
// var PostgresqlInterface = require('../../lib/postgresql_interface.js');
var db = 'psql://lamassu:lamassu@localhost/lamassu-test';
var psqlInterface = new PostgresqlInterface(db);
// var db = 'psql://lamassu:lamassu@localhost/lamassu-test';
// var psqlInterface = new PostgresqlInterface(db);
describe('trader/api', function () {
it('should throw when trying to create a trader with no DB', function () {
assert.throws(function () {
new Trader();
});
});
// describe('trader/api', function () {
// it('should throw when trying to create a trader with no DB', function () {
// assert.throws(function () {
// new Trader();
// });
// });
it('should throw when trying to configure a trader with `lowBalanceMargin` < 1', function () {
var trader = new Trader(psqlInterface);
assert.throws(function () {
trader.configure({
exchanges: {
settings: {
lowBalanceMargin: 0.8
}
}
});
});
});
// it('should throw when trying to configure a trader with `lowBalanceMargin` < 1', function () {
// var trader = new Trader(psqlInterface);
// assert.throws(function () {
// trader.configure({
// exchanges: {
// settings: {
// lowBalanceMargin: 0.8
// }
// }
// });
// });
// });
it('should find and instantiate ticker and trade exchanges', function () {
var trader = new Trader(psqlInterface);
trader.configure({
exchanges: {
plugins: {
current: {
ticker: 'bitpay',
transfer: 'blockchain'
},
settings: {
bitpay: {},
blockchain: {}
}
},
settings: {
currency: 'USD',
lowBalanceMargin: 2
}
}
});
// it('should find and instantiate ticker and trade exchanges', function () {
// var trader = new Trader(psqlInterface);
// trader.configure({
// exchanges: {
// plugins: {
// current: {
// ticker: 'bitpay',
// transfer: 'blockchain'
// },
// settings: {
// bitpay: {},
// blockchain: {}
// }
// },
// settings: {
// currency: 'USD',
// lowBalanceMargin: 2
// }
// }
// });
assert.ok(trader.tickerExchange);
assert.ok(trader.transferExchange);
});
});
// assert.ok(trader.tickerExchange);
// assert.ok(trader.transferExchange);
// });
// });