Infura Network response tests

feature/default_network_editable
tmashuang 7 years ago
parent 9d3207fb73
commit bda52f7cba
  1. 1
      app/scripts/controllers/infura.js
  2. 92
      test/unit/infura-controller-test.js

@ -26,6 +26,7 @@ class InfuraController {
this.store.updateState({ this.store.updateState({
infuraNetworkStatus: parsedResponse, infuraNetworkStatus: parsedResponse,
}) })
return parsedResponse
}) })
} }

@ -1,34 +1,58 @@
// polyfill fetch const assert = require('assert')
// global.fetch = function () {return Promise.resolve({ const InfuraController = require('../../app/scripts/controllers/infura')
// json: () => { return Promise.resolve({"mainnet": "ok", "ropsten": "degraded", "kovan": "down", "rinkeby": "ok"}) },
// }) describe('infura-controller', function () {
// } var infuraController
// const assert = require('assert') let response
// const InfuraController = require('../../app/scripts/controllers/infura')
// before(async function () {
// describe('infura-controller', function () { infuraController = new InfuraController()
// var infuraController response = await infuraController.checkInfuraNetworkStatus()
// })
// beforeEach(function () {
// infuraController = new InfuraController() describe('Network status queries', function () {
// }) it('should return object/json', function () {
// assert.equal(typeof response, 'object')
// describe('network status queries', function () { })
// describe('#checkInfuraNetworkStatus', function () {
// it('should return an object reflecting the network statuses', function (done) { describe('Mainnet', function () {
// this.timeout(15000) it('should have Mainnet', function () {
// infuraController.checkInfuraNetworkStatus() assert.equal(Object.keys(response)[0], 'mainnet')
// .then(() => { })
// const networkStatus = infuraController.store.getState().infuraNetworkStatus
// assert.equal(Object.keys(networkStatus).length, 4) it('should have a value for Mainnet status', function () {
// assert.equal(networkStatus.mainnet, 'ok') assert(response.mainnet, 'Mainnet status')
// assert.equal(networkStatus.ropsten, 'degraded') })
// assert.equal(networkStatus.kovan, 'down') })
// })
// .then(() => done()) describe('Ropsten', function () {
// .catch(done) 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')
})
})
})
})

Loading…
Cancel
Save