aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorKevin Serrano <kevgagser@gmail.com>2016-07-21 23:47:03 +0800
committerKevin Serrano <kevgagser@gmail.com>2016-07-21 23:47:03 +0800
commitaac810b1eb3414c907010c30537b7014f303d20f (patch)
treebe963fe019c52e9f317ddafbdce20ee476d595e0 /test
parent5b895c2a229555f127e1bd4b6f5c2973a37537cc (diff)
downloadtangerine-wallet-browser-aac810b1eb3414c907010c30537b7014f303d20f.tar
tangerine-wallet-browser-aac810b1eb3414c907010c30537b7014f303d20f.tar.gz
tangerine-wallet-browser-aac810b1eb3414c907010c30537b7014f303d20f.tar.bz2
tangerine-wallet-browser-aac810b1eb3414c907010c30537b7014f303d20f.tar.lz
tangerine-wallet-browser-aac810b1eb3414c907010c30537b7014f303d20f.tar.xz
tangerine-wallet-browser-aac810b1eb3414c907010c30537b7014f303d20f.tar.zst
tangerine-wallet-browser-aac810b1eb3414c907010c30537b7014f303d20f.zip
Progress on config manager. Plus tests.
Diffstat (limited to 'test')
-rw-r--r--test/unit/config-manager-test.js82
1 files changed, 81 insertions, 1 deletions
diff --git a/test/unit/config-manager-test.js b/test/unit/config-manager-test.js
index 8974a6bc5..cf8362108 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,86 @@ 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('#setConversionRate', 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.setConversionRate().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.setConversionRate().then(function() {
+ resolve()
+ })
+ })
+
+ promise.then(function() {
+ var result = configManager.getConversionRate()
+ assert.equal(typeof result, 'number')
+ done()
+ }).catch(function(err) {
+ console.log(err)
+ })
+ })
+
+ xit('should activate every time the currency is changed.', function() {
+
+ })
+ })
+ })
+
describe('confirmation', function() {
describe('#getConfirmed', function() {
@@ -215,4 +296,3 @@ describe('config-manager', function() {
})
})
})
-