aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/currency-controller-test.js
diff options
context:
space:
mode:
authorThomas Huang <thomas.b.huang@gmail.com>2017-05-05 05:35:10 +0800
committerThomas Huang <thomas.b.huang@gmail.com>2017-05-05 05:35:10 +0800
commit0b13429daf00ddd5bdf2705c7a95d7a9d5792f54 (patch)
treef249d8deb5fa48db54d70757de944b2c8ff76a2e /test/unit/currency-controller-test.js
parent8f5334e4aca8b95963f57b0fbf862256b692dbd9 (diff)
downloadtangerine-wallet-browser-0b13429daf00ddd5bdf2705c7a95d7a9d5792f54.tar
tangerine-wallet-browser-0b13429daf00ddd5bdf2705c7a95d7a9d5792f54.tar.gz
tangerine-wallet-browser-0b13429daf00ddd5bdf2705c7a95d7a9d5792f54.tar.bz2
tangerine-wallet-browser-0b13429daf00ddd5bdf2705c7a95d7a9d5792f54.tar.lz
tangerine-wallet-browser-0b13429daf00ddd5bdf2705c7a95d7a9d5792f54.tar.xz
tangerine-wallet-browser-0b13429daf00ddd5bdf2705c7a95d7a9d5792f54.tar.zst
tangerine-wallet-browser-0b13429daf00ddd5bdf2705c7a95d7a9d5792f54.zip
Lint tests
Diffstat (limited to 'test/unit/currency-controller-test.js')
-rw-r--r--test/unit/currency-controller-test.js45
1 files changed, 21 insertions, 24 deletions
diff --git a/test/unit/currency-controller-test.js b/test/unit/currency-controller-test.js
index 079f8b488..40868912c 100644
--- a/test/unit/currency-controller-test.js
+++ b/test/unit/currency-controller-test.js
@@ -2,26 +2,25 @@
global.fetch = global.fetch || require('isomorphic-fetch')
const assert = require('assert')
-const extend = require('xtend')
-const rp = require('request-promise')
+// const extend = require('xtend')
+// const rp = require('request-promise')
const nock = require('nock')
const CurrencyController = require('../../app/scripts/controllers/currency')
-describe('currency-controller', function() {
+describe('currency-controller', function () {
var currencyController
- beforeEach(function() {
+ beforeEach(function () {
currencyController = new CurrencyController()
})
- describe('currency conversions', function() {
-
- describe('#setCurrentCurrency', function() {
- it('should return USD as default', function() {
+ 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() {
+ it('should be able to set to other currency', function () {
assert.equal(currencyController.getCurrentCurrency(), 'USD')
currencyController.setCurrentCurrency('JPY')
var result = currencyController.getCurrentCurrency()
@@ -29,39 +28,38 @@ describe('currency-controller', function() {
})
})
- describe('#getConversionRate', function() {
- it('should return undefined if non-existent', function() {
+ 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) {
+ 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')
+ 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(currencyController.getConversionRate(), 0)
currencyController.setCurrentCurrency('USD')
currencyController.updateConversionRate()
- .then(function() {
+ .then(function () {
var result = currencyController.getConversionRate()
console.log('currencyController.getConversionRate:', result)
assert.equal(typeof result, 'number')
done()
- }).catch(function(err) {
+ }).catch(function (err) {
done(err)
})
-
})
- it('should work for JPY as well.', function() {
+ it('should work for JPY as well.', function () {
this.timeout(15000)
assert.equal(currencyController.getConversionRate(), 0)
- var jpyMock = nock('https://www.cryptonator.com')
+ 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":""}')
@@ -69,19 +67,18 @@ describe('currency-controller', function() {
var promise = new Promise(
function (resolve, reject) {
currencyController.setCurrentCurrency('JPY')
- currencyController.updateConversionRate().then(function() {
+ currencyController.updateConversionRate().then(function () {
resolve()
})
- })
+ })
- promise.then(function() {
+ promise.then(function () {
var result = currencyController.getConversionRate()
assert.equal(typeof result, 'number')
- }).catch(function(err) {
+ }).catch(function (done, err) {
done(err)
})
})
})
})
-
})