aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/config-manager.js
diff options
context:
space:
mode:
authorKevin Serrano <kevgagser@gmail.com>2016-08-25 04:28:06 +0800
committerKevin Serrano <kevgagser@gmail.com>2016-08-25 04:28:06 +0800
commitd3d634d09c0c51ade2d750ee2d7f036f797757b0 (patch)
treef29e06912a5ee01045e5e306d4fa1b82d8258e80 /app/scripts/lib/config-manager.js
parent55745c59805e691e75b2ceabdbc353032971cc8e (diff)
downloadtangerine-wallet-browser-d3d634d09c0c51ade2d750ee2d7f036f797757b0.tar
tangerine-wallet-browser-d3d634d09c0c51ade2d750ee2d7f036f797757b0.tar.gz
tangerine-wallet-browser-d3d634d09c0c51ade2d750ee2d7f036f797757b0.tar.bz2
tangerine-wallet-browser-d3d634d09c0c51ade2d750ee2d7f036f797757b0.tar.lz
tangerine-wallet-browser-d3d634d09c0c51ade2d750ee2d7f036f797757b0.tar.xz
tangerine-wallet-browser-d3d634d09c0c51ade2d750ee2d7f036f797757b0.tar.zst
tangerine-wallet-browser-d3d634d09c0c51ade2d750ee2d7f036f797757b0.zip
Added mock option to function.
Diffstat (limited to 'app/scripts/lib/config-manager.js')
-rw-r--r--app/scripts/lib/config-manager.js36
1 files changed, 23 insertions, 13 deletions
diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js
index 4d270bcdb..a37447fa2 100644
--- a/app/scripts/lib/config-manager.js
+++ b/app/scripts/lib/config-manager.js
@@ -288,21 +288,32 @@ ConfigManager.prototype.getCurrentFiat = function () {
return ('fiatCurrency' in data) && data.fiatCurrency
}
-ConfigManager.prototype.updateConversionRate = function () {
+ConfigManager.prototype.updateConversionRate = function (mock = false, mockCurrency = 'USD') {
var data = this.getData()
- return rp(`https://www.cryptonator.com/api/ticker/eth-${data.fiatCurrency}`)
- .then((response) => {
- const parsedResponse = JSON.parse(response)
- this.setConversionPrice(parsedResponse.ticker.price)
- this.setConversionDate(parsedResponse.timestamp)
- }).catch((err) => {
- console.error('Error in conversion.', err)
- this.setConversionPrice(0)
- this.setConversionDate('N/A')
- })
+ if (!mock) {
+ return rp(`https://www.cryptonator.com/api/ticker/eth-${data.fiatCurrency}`)
+ .then((response) => {
+ const parsedResponse = JSON.parse(response)
+ this.setConversionPrice(parsedResponse.ticker.price)
+ this.setConversionDate(parsedResponse.timestamp)
+ }).catch((err) => {
+ console.error('Error in conversion.', err)
+ this.setConversionPrice(0)
+ this.setConversionDate('N/A')
+ })
+ } else {
+ return new Promise(function(resolve, reject) { resolve() }).then((response) => {
+ this.setConversionPrice('11.01')
+ this.setConversionDate(1472065924)
+ }).catch((err) => {
+ console.error('Error in conversion.', err)
+ this.setConversionPrice('11.01')
+ this.setConversionDate(1472065924)
+ })
+ }
}
-ConfigManager.prototype.setConversionPrice = function(price) {
+ConfigManager.prototype.setConversionPrice = function (price) {
var data = this.getData()
data.conversionRate = Number(price)
this.setData(data)
@@ -372,4 +383,3 @@ ConfigManager.prototype.createShapeShiftTx = function (depositAddress, depositTy
}
this.setData(data)
}
-