|
|
|
@ -4,6 +4,7 @@ const STORAGE_KEY = 'metamask-persistance-key' |
|
|
|
|
var configManagerGen = require('../lib/mock-config-manager') |
|
|
|
|
var configManager |
|
|
|
|
const rp = require('request-promise') |
|
|
|
|
const nock = require('nock') |
|
|
|
|
|
|
|
|
|
describe('config-manager', function() { |
|
|
|
|
|
|
|
|
@ -47,12 +48,15 @@ describe('config-manager', function() { |
|
|
|
|
describe('#updateConversionRate', function() { |
|
|
|
|
it('should retrieve an update for ETH to USD and set it in memory', function(done) { |
|
|
|
|
this.timeout(15000) |
|
|
|
|
var usdMock = nock('https://www.cryptonator.com') |
|
|
|
|
.get('/api/ticker/eth-USD') |
|
|
|
|
.reply(200, '{"ticker":{"base":"ETH","target":"USD","price":"11.02456145","volume":"44948.91745289","change":"-0.01472534"},"timestamp":1472072136,"success":true,"error":""}') |
|
|
|
|
|
|
|
|
|
assert.equal(configManager.getConversionRate(), false) |
|
|
|
|
var promise = new Promise( |
|
|
|
|
function (resolve, reject) { |
|
|
|
|
configManager.setCurrentFiat('USD') |
|
|
|
|
configManager.updateConversionRate(true, 'USD').then(function() { |
|
|
|
|
configManager.updateConversionRate().then(function() { |
|
|
|
|
resolve() |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
@ -71,10 +75,15 @@ describe('config-manager', function() { |
|
|
|
|
this.timeout(15000) |
|
|
|
|
assert.equal(configManager.getConversionRate(), false) |
|
|
|
|
|
|
|
|
|
var usdMock = nock('https://www.cryptonator.com') |
|
|
|
|
.get('/api/ticker/eth-JPY') |
|
|
|
|
.reply(200, '{"ticker":{"base":"ETH","target":"JPY","price":"11.02456145","volume":"44948.91745289","change":"-0.01472534"},"timestamp":1472072136,"success":true,"error":""}') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var promise = new Promise( |
|
|
|
|
function (resolve, reject) { |
|
|
|
|
configManager.setCurrentFiat('JPY') |
|
|
|
|
configManager.updateConversionRate(true, 'JPY').then(function() { |
|
|
|
|
configManager.updateConversionRate().then(function() { |
|
|
|
|
resolve() |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|