aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortmashuang <tmashuang@gmail.com>2017-07-15 01:34:03 +0800
committertmashuang <tmashuang@gmail.com>2017-07-15 01:34:03 +0800
commitbda52f7cba9cd866d2244c402fed2e82e1366005 (patch)
treeda060759010d931aa6a199cde3ca92de9cdf4a9f
parent9d3207fb7302e74d3d2f8ffad12d50dfd3885fdc (diff)
downloadtangerine-wallet-browser-bda52f7cba9cd866d2244c402fed2e82e1366005.tar
tangerine-wallet-browser-bda52f7cba9cd866d2244c402fed2e82e1366005.tar.gz
tangerine-wallet-browser-bda52f7cba9cd866d2244c402fed2e82e1366005.tar.bz2
tangerine-wallet-browser-bda52f7cba9cd866d2244c402fed2e82e1366005.tar.lz
tangerine-wallet-browser-bda52f7cba9cd866d2244c402fed2e82e1366005.tar.xz
tangerine-wallet-browser-bda52f7cba9cd866d2244c402fed2e82e1366005.tar.zst
tangerine-wallet-browser-bda52f7cba9cd866d2244c402fed2e82e1366005.zip
Infura Network response tests
-rw-r--r--app/scripts/controllers/infura.js1
-rw-r--r--test/unit/infura-controller-test.js92
2 files changed, 59 insertions, 34 deletions
diff --git a/app/scripts/controllers/infura.js b/app/scripts/controllers/infura.js
index 98375b446..b34b0bc03 100644
--- a/app/scripts/controllers/infura.js
+++ b/app/scripts/controllers/infura.js
@@ -26,6 +26,7 @@ class InfuraController {
this.store.updateState({
infuraNetworkStatus: parsedResponse,
})
+ return parsedResponse
})
}
diff --git a/test/unit/infura-controller-test.js b/test/unit/infura-controller-test.js
index 912867764..b9050f4c2 100644
--- a/test/unit/infura-controller-test.js
+++ b/test/unit/infura-controller-test.js
@@ -1,34 +1,58 @@
-// polyfill fetch
-// global.fetch = function () {return Promise.resolve({
-// json: () => { return Promise.resolve({"mainnet": "ok", "ropsten": "degraded", "kovan": "down", "rinkeby": "ok"}) },
-// })
-// }
-// const assert = require('assert')
-// const InfuraController = require('../../app/scripts/controllers/infura')
-//
-// describe('infura-controller', function () {
-// var infuraController
-//
-// beforeEach(function () {
-// infuraController = new InfuraController()
-// })
-//
-// describe('network status queries', function () {
-// describe('#checkInfuraNetworkStatus', function () {
-// it('should return an object reflecting the network statuses', function (done) {
-// this.timeout(15000)
-// infuraController.checkInfuraNetworkStatus()
-// .then(() => {
-// const networkStatus = infuraController.store.getState().infuraNetworkStatus
-// assert.equal(Object.keys(networkStatus).length, 4)
-// assert.equal(networkStatus.mainnet, 'ok')
-// assert.equal(networkStatus.ropsten, 'degraded')
-// assert.equal(networkStatus.kovan, 'down')
-// })
-// .then(() => done())
-// .catch(done)
-//
-// })
-// })
-// })
-// })
+const assert = require('assert')
+const InfuraController = require('../../app/scripts/controllers/infura')
+
+describe('infura-controller', function () {
+ var infuraController
+ let response
+
+ before(async function () {
+ infuraController = new InfuraController()
+ response = await infuraController.checkInfuraNetworkStatus()
+ })
+
+ describe('Network status queries', function () {
+ it('should return object/json', function () {
+ assert.equal(typeof response, 'object')
+ })
+
+ describe('Mainnet', function () {
+ it('should have Mainnet', function () {
+ assert.equal(Object.keys(response)[0], 'mainnet')
+ })
+
+ it('should have a value for Mainnet status', function () {
+ assert(response.mainnet, 'Mainnet status')
+ })
+ })
+
+ describe('Ropsten', function () {
+ it('should have Ropsten', function () {
+ assert.equal(Object.keys(response)[1], 'ropsten')
+ })
+
+ it('should have a value for Ropsten status', function () {
+ assert(response.ropsten, 'Ropsten status')
+ })
+ })
+
+ describe('Kovan', function () {
+ it('should have Kovan', function () {
+ assert.equal(Object.keys(response)[2], 'kovan')
+ })
+
+ it('should have a value for Kovan status', function () {
+ assert(response.kovan, 'Kovan status')
+ })
+ })
+
+ describe('Rinkeby', function () {
+ it('should have Rinkeby', function () {
+ assert.equal(Object.keys(response)[3], 'rinkeby')
+ })
+
+ it('should have a value for Rinkeby status', function () {
+ assert(response.rinkeby, 'Rinkeby status')
+ })
+ })
+ })
+})