aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorPaul Bouchon <mail@bitpshr.net>2019-06-01 06:14:22 +0800
committerGitHub <noreply@github.com>2019-06-01 06:14:22 +0800
commit47024fd9a530c1554cfa74c8e74f6221e00c6135 (patch)
tree4abdaecc6c3de3f6ab6ff83268bf8b93cdee5e8d /test/unit
parent44616befc71bc561887569ae7b523831ab470487 (diff)
downloadtangerine-wallet-browser-47024fd9a530c1554cfa74c8e74f6221e00c6135.tar
tangerine-wallet-browser-47024fd9a530c1554cfa74c8e74f6221e00c6135.tar.gz
tangerine-wallet-browser-47024fd9a530c1554cfa74c8e74f6221e00c6135.tar.bz2
tangerine-wallet-browser-47024fd9a530c1554cfa74c8e74f6221e00c6135.tar.lz
tangerine-wallet-browser-47024fd9a530c1554cfa74c8e74f6221e00c6135.tar.xz
tangerine-wallet-browser-47024fd9a530c1554cfa74c8e74f6221e00c6135.tar.zst
tangerine-wallet-browser-47024fd9a530c1554cfa74c8e74f6221e00c6135.zip
feature: integrate gaba/CurrencyRateController (#6570)
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/app/controllers/currency-controller-test.js78
-rw-r--r--test/unit/app/controllers/metamask-controller-test.js9
2 files changed, 7 insertions, 80 deletions
diff --git a/test/unit/app/controllers/currency-controller-test.js b/test/unit/app/controllers/currency-controller-test.js
deleted file mode 100644
index 8b6fbb719..000000000
--- a/test/unit/app/controllers/currency-controller-test.js
+++ /dev/null
@@ -1,78 +0,0 @@
-const assert = require('assert')
-const nock = require('nock')
-const CurrencyController = require('../../../../app/scripts/controllers/currency')
-
-describe('currency-controller', function () {
- var currencyController
-
- beforeEach(function () {
- currencyController = new CurrencyController()
- })
-
- describe('currency conversions', function () {
- describe('#setCurrentCurrency', function () {
- it('should return USD as default', function () {
- assert.equal(currencyController.getCurrentCurrency(), 'usd')
- })
-
- it('should be able to set to other currency', function () {
- assert.equal(currencyController.getCurrentCurrency(), 'usd')
- currencyController.setCurrentCurrency('JPY')
- var result = currencyController.getCurrentCurrency()
- assert.equal(result, 'JPY')
- })
- })
-
- describe('#getConversionRate', function () {
- it('should return undefined if non-existent', function () {
- var result = currencyController.getConversionRate()
- assert.ok(!result)
- })
- })
-
- describe('#updateConversionRate', function () {
- it('should retrieve an update for ETH to USD and set it in memory', function (done) {
- this.timeout(15000)
- nock('https://api.infura.io')
- .get('/v1/ticker/ethusd')
- .reply(200, '{"base": "ETH", "quote": "USD", "bid": 288.45, "ask": 288.46, "volume": 112888.17569277, "exchange": "bitfinex", "total_volume": 272175.00106721005, "num_exchanges": 8, "timestamp": 1506444677}')
-
- assert.equal(currencyController.getConversionRate(), 0)
- currencyController.setCurrentCurrency('usd')
- currencyController.updateConversionRate()
- .then(function () {
- var result = currencyController.getConversionRate()
- assert.equal(typeof result, 'number')
- done()
- }).catch(function (err) {
- done(err)
- })
- })
-
- it('should work for JPY as well.', function () {
- this.timeout(15000)
- assert.equal(currencyController.getConversionRate(), 0)
-
- nock('https://api.infura.io')
- .get('/v1/ticker/ethjpy')
- .reply(200, '{"base": "ETH", "quote": "JPY", "bid": 32300.0, "ask": 32400.0, "volume": 247.4616071, "exchange": "kraken", "total_volume": 247.4616071, "num_exchanges": 1, "timestamp": 1506444676}')
-
-
- var promise = new Promise(
- function (resolve) {
- currencyController.setCurrentCurrency('jpy')
- currencyController.updateConversionRate().then(function () {
- resolve()
- })
- })
-
- promise.then(function () {
- var result = currencyController.getConversionRate()
- assert.equal(typeof result, 'number')
- }).catch(function (done, err) {
- done(err)
- })
- })
- })
- })
-})
diff --git a/test/unit/app/controllers/metamask-controller-test.js b/test/unit/app/controllers/metamask-controller-test.js
index a56b8adbd..1b8cde42e 100644
--- a/test/unit/app/controllers/metamask-controller-test.js
+++ b/test/unit/app/controllers/metamask-controller-test.js
@@ -45,6 +45,11 @@ describe('MetaMaskController', function () {
.get(/.*/)
.reply(200)
+ nock('https://min-api.cryptocompare.com')
+ .persist()
+ .get(/.*/)
+ .reply(200, '{"JPY":12415.9}')
+
metamaskController = new MetaMaskController({
showUnapprovedTx: noop,
showUnconfirmedMessage: noop,
@@ -441,7 +446,7 @@ describe('MetaMaskController', function () {
let defaultMetaMaskCurrency
beforeEach(function () {
- defaultMetaMaskCurrency = metamaskController.currencyController.getCurrentCurrency()
+ defaultMetaMaskCurrency = metamaskController.currencyRateController.state.currentCurrency
})
it('defaults to usd', function () {
@@ -450,7 +455,7 @@ describe('MetaMaskController', function () {
it('sets currency to JPY', function () {
metamaskController.setCurrentCurrency('JPY', noop)
- assert.equal(metamaskController.currencyController.getCurrentCurrency(), 'JPY')
+ assert.equal(metamaskController.currencyRateController.state.currentCurrency, 'JPY')
})
})