diff options
author | Dan Finlay <dan@danfinlay.com> | 2016-08-17 06:41:11 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2016-08-17 06:41:11 +0800 |
commit | 4ba90969ee8fa9b9e21e88f5c6f0d646874049a3 (patch) | |
tree | 8b6f9423b1895aa7973737315857066a56855621 /test | |
parent | 5479509618e601391586d0851acee4e408523c4f (diff) | |
parent | 90d6bec3ed51ba4b2d4696132642a4d97712dec9 (diff) | |
download | tangerine-wallet-browser-4ba90969ee8fa9b9e21e88f5c6f0d646874049a3.tar tangerine-wallet-browser-4ba90969ee8fa9b9e21e88f5c6f0d646874049a3.tar.gz tangerine-wallet-browser-4ba90969ee8fa9b9e21e88f5c6f0d646874049a3.tar.bz2 tangerine-wallet-browser-4ba90969ee8fa9b9e21e88f5c6f0d646874049a3.tar.lz tangerine-wallet-browser-4ba90969ee8fa9b9e21e88f5c6f0d646874049a3.tar.xz tangerine-wallet-browser-4ba90969ee8fa9b9e21e88f5c6f0d646874049a3.tar.zst tangerine-wallet-browser-4ba90969ee8fa9b9e21e88f5c6f0d646874049a3.zip |
Merge branch 'master' into PopupNotifications
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/config-manager-test.js | 77 |
1 files changed, 76 insertions, 1 deletions
diff --git a/test/unit/config-manager-test.js b/test/unit/config-manager-test.js index 8974a6bc5..b34089163 100644 --- a/test/unit/config-manager-test.js +++ b/test/unit/config-manager-test.js @@ -3,6 +3,7 @@ const extend = require('xtend') const STORAGE_KEY = 'metamask-persistance-key' var configManagerGen = require('../lib/mock-config-manager') var configManager +const rp = require('request-promise') describe('config-manager', function() { @@ -11,6 +12,81 @@ describe('config-manager', function() { configManager = configManagerGen() }) + describe('currency conversions', function() { + + describe('#getCurrentFiat', function() { + it('should return false if no previous key exists', function() { + var result = configManager.getCurrentFiat() + assert.ok(!result) + }) + }) + + describe('#setCurrentFiat', function() { + it('should make getCurrentFiat return true once set', function() { + assert.equal(configManager.getCurrentFiat(), false) + configManager.setCurrentFiat('USD') + var result = configManager.getCurrentFiat() + assert.equal(result, 'USD') + }) + + it('should work with other currencies as well', function() { + assert.equal(configManager.getCurrentFiat(), false) + configManager.setCurrentFiat('JPY') + var result = configManager.getCurrentFiat() + assert.equal(result, 'JPY') + }) + }) + + describe('#getConversionRate', function() { + it('should return false if non-existent', function() { + var result = configManager.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) + assert.equal(configManager.getConversionRate(), false) + var promise = new Promise( + function (resolve, reject) { + configManager.setCurrentFiat('USD') + configManager.updateConversionRate().then(function() { + resolve() + }) + }) + + promise.then(function() { + var result = configManager.getConversionRate() + assert.equal(typeof result, 'number') + done() + }).catch(function(err) { + console.log(err) + }) + + }) + + it('should work for JPY as well.', function() { + this.timeout(15000) + assert.equal(configManager.getConversionRate(), false) + var promise = new Promise( + function (resolve, reject) { + configManager.setCurrentFiat('JPY') + configManager.updateConversionRate().then(function() { + resolve() + }) + }) + + promise.then(function() { + var result = configManager.getConversionRate() + assert.equal(typeof result, 'number') + }).catch(function(err) { + console.log(err) + }) + }) + }) + }) + describe('confirmation', function() { describe('#getConfirmed', function() { @@ -215,4 +291,3 @@ describe('config-manager', function() { }) }) }) - |