test specific provider
This commit is contained in:
parent
e62e5b032d
commit
5d868d57c4
|
@ -110,11 +110,11 @@ FiatRateService.prototype.getRate = function(code, opts, cb) {
|
|||
|
||||
opts = opts || {};
|
||||
|
||||
var providerName = opts.providerName || DEFAULT_PROVIDER;
|
||||
var provider = opts.provider || DEFAULT_PROVIDER;
|
||||
var ts = opts.ts || Date.now();
|
||||
|
||||
async.map([].concat(ts), function(ts, cb) {
|
||||
self.storage.fetchFiatRate(providerName, code, ts, function(err, rate) {
|
||||
self.storage.fetchFiatRate(provider, code, ts, function(err, rate) {
|
||||
if (err) return cb(err);
|
||||
return cb(null, {
|
||||
ts: +ts,
|
||||
|
|
|
@ -67,6 +67,33 @@ describe.only('Fiat rate service', function() {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should get current rate for different provider', function(done) {
|
||||
service.storage.storeFiatRate('BitPay', [{
|
||||
code: 'USD',
|
||||
value: 100.00,
|
||||
}], function(err) {
|
||||
should.not.exist(err);
|
||||
service.storage.storeFiatRate('Bitstamp', [{
|
||||
code: 'USD',
|
||||
value: 200.00,
|
||||
}], function(err) {
|
||||
should.not.exist(err);
|
||||
service.getRate('USD', {}, function(err, res) {
|
||||
should.not.exist(err);
|
||||
res.rate.should.equal(100.00, 'Should use default provider');
|
||||
service.getRate('USD', {
|
||||
provider: 'Bitstamp'
|
||||
}, function(err, res) {
|
||||
should.not.exist(err);
|
||||
res.rate.should.equal(200.00);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should get rate for specific ts', function(done) {
|
||||
var clock = sinon.useFakeTimers(0, 'Date');
|
||||
clock.tick(20);
|
||||
|
|
Loading…
Reference in New Issue