Merge pull request #36 from chester1000/jshint
style(jshint): jshint compatibility ensured
This commit is contained in:
commit
63a9b67614
2 changed files with 30 additions and 26 deletions
|
|
@ -37,7 +37,7 @@ exports.init = function init(databaseHandle) {
|
|||
}
|
||||
|
||||
db = databaseHandle;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
function loadPlugin(name, config) {
|
||||
|
|
@ -91,7 +91,7 @@ function loadPlugin(name, config) {
|
|||
|
||||
|
||||
return plugin;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
exports.configure = function configure(config) {
|
||||
|
|
@ -100,7 +100,7 @@ exports.configure = function configure(config) {
|
|||
}
|
||||
|
||||
deviceCurrency = config.exchanges.settings.currency;
|
||||
var plugins = config.exchanges.plugins
|
||||
var plugins = config.exchanges.plugins;
|
||||
|
||||
// [required] configure (or load) ticker
|
||||
var tickerName = plugins.current.ticker;
|
||||
|
|
@ -272,7 +272,7 @@ function stopPolling() {
|
|||
clearInterval(balanceInterval);
|
||||
clearInterval(rateInterval);
|
||||
// clearInterval(tradeInterval); // TODO: should this get cleared too?
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function pollBalance(callback) {
|
||||
|
|
@ -300,7 +300,7 @@ function pollBalance(callback) {
|
|||
|
||||
return callback && callback(null, lastBalances);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function pollRate(callback) {
|
||||
logger.debug('polling for rates');
|
||||
|
|
@ -317,7 +317,7 @@ function pollRate(callback) {
|
|||
|
||||
return callback && callback(null, lastRates);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -330,7 +330,7 @@ function getLastRate(currency) {
|
|||
if (!lastRates[tmpCurrency]) return null;
|
||||
|
||||
return lastRates[tmpCurrency];
|
||||
};
|
||||
}
|
||||
exports.getDeviceRate = function getDeviceRate() {
|
||||
return getLastRate(deviceCurrency);
|
||||
};
|
||||
|
|
@ -347,19 +347,19 @@ function clearSession(deviceFingerprint) {
|
|||
clearTimeout(session.reaper);
|
||||
delete sessions[deviceFingerprint];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Trader functions
|
||||
*/
|
||||
function purchase(trade, callback) {
|
||||
traderPlugin.purchase(trade.satoshis, null, function(err, _) {
|
||||
traderPlugin.purchase(trade.satoshis, null, function(err) {
|
||||
if (err) return callback(err);
|
||||
pollBalance();
|
||||
callback && callback();
|
||||
if (typeof callback === 'function') callback();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function consolidateTrades() {
|
||||
// NOTE: value in satoshis stays the same no matter the currency
|
||||
|
|
@ -374,7 +374,7 @@ function consolidateTrades() {
|
|||
|
||||
logger.debug('consolidated: ', JSON.stringify(consolidatedTrade));
|
||||
return consolidatedTrade;
|
||||
};
|
||||
}
|
||||
|
||||
function executeTrades() {
|
||||
if (!traderPlugin) return;
|
||||
|
|
@ -395,7 +395,7 @@ function executeTrades() {
|
|||
logger.error(err);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
* ID Verifier functions
|
||||
|
|
@ -405,5 +405,5 @@ exports.verifyUser = function verifyUser(data, callback) {
|
|||
};
|
||||
|
||||
exports.verifyTransaction = function verifyTransaction(data, callback) {
|
||||
idVerifier.verifyTransaction(data, callback);
|
||||
idVerifierPlugin.verifyTransaction(data, callback);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
'use strict'
|
||||
/* global describe, it, before, afterEach */
|
||||
|
||||
'use strict';
|
||||
|
||||
var _ = require('lodash');
|
||||
var should = require('chai').should();
|
||||
|
|
@ -9,11 +11,9 @@ var config = require('./mocks/config');
|
|||
var CONFIG = _.cloneDeep(config);
|
||||
function requireFreshConfig() {
|
||||
return _.cloneDeep(CONFIG);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
var currents = config.exchanges.plugins.current;
|
||||
|
||||
var walletMock = require('./mocks/wallet');
|
||||
var tickerMock = require('./mocks/ticker');
|
||||
var traderMock = require('./mocks/trader');
|
||||
|
|
@ -51,11 +51,11 @@ describe('Plugins', function() {
|
|||
});
|
||||
|
||||
it('should throw when invalid balance margin', function() {
|
||||
config.exchanges.settings.lowBalanceMargin = .99;
|
||||
config.exchanges.settings.lowBalanceMargin = 0.99;
|
||||
|
||||
function configurer() {
|
||||
plugins.configure(config);
|
||||
};
|
||||
}
|
||||
configurer.should.throw(/lowBalanceMargin/);
|
||||
});
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ describe('Plugins', function() {
|
|||
|
||||
function configurer() {
|
||||
plugins.configure(config);
|
||||
};
|
||||
}
|
||||
configurer.should.throw(/module.*not installed/);
|
||||
});
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ describe('Plugins', function() {
|
|||
|
||||
function configurer() {
|
||||
plugins.configure(config);
|
||||
};
|
||||
}
|
||||
configurer.should.throw(/required.*SUPPORTED_MODULES/);
|
||||
|
||||
tickerMock.SUPPORTED_MODULES = tmp;
|
||||
|
|
@ -86,7 +86,7 @@ describe('Plugins', function() {
|
|||
|
||||
function configurer() {
|
||||
plugins.configure(config);
|
||||
};
|
||||
}
|
||||
configurer.should.throw(/fails.*implement.*method/);
|
||||
|
||||
tickerMock.ticker = tmp;
|
||||
|
|
@ -97,12 +97,14 @@ describe('Plugins', function() {
|
|||
|
||||
before(function() {
|
||||
function configTest(name) {
|
||||
return function config(config) {
|
||||
return function config(localConfig) {
|
||||
should.exist(config);
|
||||
config.should.be.an.Object;
|
||||
/* jshint expr: true */
|
||||
localConfig.should.be.an.Object;
|
||||
/* jshint expr: true */
|
||||
confList[name] = config;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
walletMock.config = configTest('wallet');
|
||||
tickerMock.config = configTest('ticker');
|
||||
|
|
@ -116,7 +118,9 @@ describe('Plugins', function() {
|
|||
it('should configure ' + name, function() {
|
||||
confList.should.have.property(name);
|
||||
should.exist(confList[name]);
|
||||
/* jshint expr: true */
|
||||
confList[name].should.be.an.Object;
|
||||
/* jshint expr: true */
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue