aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkumavis <kumavis@users.noreply.github.com>2017-07-15 05:39:18 +0800
committerGitHub <noreply@github.com>2017-07-15 05:39:18 +0800
commit43a3d0d01dba21f9f4f2863025144555327411d4 (patch)
treedd959bb142a1e339118d3d2de1e032942c46efa5
parent9d3207fb7302e74d3d2f8ffad12d50dfd3885fdc (diff)
parenta4c7d95d0de01a37c1e9debea51eb9e2fd8bc2a7 (diff)
downloadtangerine-wallet-browser-43a3d0d01dba21f9f4f2863025144555327411d4.tar
tangerine-wallet-browser-43a3d0d01dba21f9f4f2863025144555327411d4.tar.gz
tangerine-wallet-browser-43a3d0d01dba21f9f4f2863025144555327411d4.tar.bz2
tangerine-wallet-browser-43a3d0d01dba21f9f4f2863025144555327411d4.tar.lz
tangerine-wallet-browser-43a3d0d01dba21f9f4f2863025144555327411d4.tar.xz
tangerine-wallet-browser-43a3d0d01dba21f9f4f2863025144555327411d4.tar.zst
tangerine-wallet-browser-43a3d0d01dba21f9f4f2863025144555327411d4.zip
Merge pull request #1777 from MetaMask/InfuraTest
Infura Network response tests
-rw-r--r--app/scripts/controllers/infura.js1
-rw-r--r--package.json2
-rw-r--r--test/unit/infura-controller-test.js96
3 files changed, 64 insertions, 35 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/package.json b/package.json
index 1f2d0d591..e0bb303bf 100644
--- a/package.json
+++ b/package.json
@@ -176,7 +176,7 @@
"react-addons-test-utils": "^15.5.1",
"react-test-renderer": "^15.5.4",
"react-testutils-additions": "^15.2.0",
- "sinon": "^1.17.3",
+ "sinon": "^2.3.8",
"tape": "^4.5.1",
"testem": "^1.10.3",
"uglifyify": "^3.0.1",
diff --git a/test/unit/infura-controller-test.js b/test/unit/infura-controller-test.js
index 912867764..605305efa 100644
--- a/test/unit/infura-controller-test.js
+++ b/test/unit/infura-controller-test.js
@@ -1,34 +1,62 @@
-// 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 sinon = require('sinon')
+const InfuraController = require('../../app/scripts/controllers/infura')
+
+describe('infura-controller', function () {
+ let infuraController, sandbox, networkStatus
+ const response = {'mainnet': 'degraded', 'ropsten': 'ok', 'kovan': 'ok', 'rinkeby': 'down'}
+
+ before(async function () {
+ infuraController = new InfuraController()
+ sandbox = sinon.sandbox.create()
+ sinon.stub(infuraController, 'checkInfuraNetworkStatus').resolves(response)
+ networkStatus = await infuraController.checkInfuraNetworkStatus()
+ })
+
+ after(function () {
+ sandbox.restore()
+ })
+
+ describe('Network status queries', function () {
+
+ describe('Mainnet', function () {
+ it('should have Mainnet', function () {
+ assert.equal(Object.keys(networkStatus)[0], 'mainnet')
+ })
+
+ it('should have a value for Mainnet status', function () {
+ assert.equal(networkStatus.mainnet, 'degraded')
+ })
+ })
+
+ describe('Ropsten', function () {
+ it('should have Ropsten', function () {
+ assert.equal(Object.keys(networkStatus)[1], 'ropsten')
+ })
+
+ it('should have a value for Ropsten status', function () {
+ assert.equal(networkStatus.ropsten, 'ok')
+ })
+ })
+
+ describe('Kovan', function () {
+ it('should have Kovan', function () {
+ assert.equal(Object.keys(networkStatus)[2], 'kovan')
+ })
+
+ it('should have a value for Kovan status', function () {
+ assert.equal(networkStatus.kovan, 'ok')
+ })
+ })
+
+ describe('Rinkeby', function () {
+ it('should have Rinkeby', function () {
+ assert.equal(Object.keys(networkStatus)[3], 'rinkeby')
+ })
+
+ it('should have a value for Rinkeby status', function () {
+ assert.equal(networkStatus.rinkeby, 'down')
+ })
+ })
+ })
+})