Merge pull request #1777 from MetaMask/InfuraTest
Infura Network response testsfeature/default_network_editable
commit
43a3d0d01d
@ -1,34 +1,62 @@ |
|||||||
// polyfill fetch
|
const assert = require('assert') |
||||||
// global.fetch = function () {return Promise.resolve({
|
const sinon = require('sinon') |
||||||
// json: () => { return Promise.resolve({"mainnet": "ok", "ropsten": "degraded", "kovan": "down", "rinkeby": "ok"}) },
|
const InfuraController = require('../../app/scripts/controllers/infura') |
||||||
// })
|
|
||||||
// }
|
describe('infura-controller', function () { |
||||||
// const assert = require('assert')
|
let infuraController, sandbox, networkStatus |
||||||
// const InfuraController = require('../../app/scripts/controllers/infura')
|
const response = {'mainnet': 'degraded', 'ropsten': 'ok', 'kovan': 'ok', 'rinkeby': 'down'} |
||||||
//
|
|
||||||
// describe('infura-controller', function () {
|
before(async function () { |
||||||
// var infuraController
|
infuraController = new InfuraController() |
||||||
//
|
sandbox = sinon.sandbox.create() |
||||||
// beforeEach(function () {
|
sinon.stub(infuraController, 'checkInfuraNetworkStatus').resolves(response) |
||||||
// infuraController = new InfuraController()
|
networkStatus = await infuraController.checkInfuraNetworkStatus() |
||||||
// })
|
}) |
||||||
//
|
|
||||||
// describe('network status queries', function () {
|
after(function () { |
||||||
// describe('#checkInfuraNetworkStatus', function () {
|
sandbox.restore() |
||||||
// it('should return an object reflecting the network statuses', function (done) {
|
}) |
||||||
// this.timeout(15000)
|
|
||||||
// infuraController.checkInfuraNetworkStatus()
|
describe('Network status queries', function () { |
||||||
// .then(() => {
|
|
||||||
// const networkStatus = infuraController.store.getState().infuraNetworkStatus
|
describe('Mainnet', function () { |
||||||
// assert.equal(Object.keys(networkStatus).length, 4)
|
it('should have Mainnet', function () { |
||||||
// assert.equal(networkStatus.mainnet, 'ok')
|
assert.equal(Object.keys(networkStatus)[0], 'mainnet') |
||||||
// assert.equal(networkStatus.ropsten, 'degraded')
|
}) |
||||||
// assert.equal(networkStatus.kovan, 'down')
|
|
||||||
// })
|
it('should have a value for Mainnet status', function () { |
||||||
// .then(() => done())
|
assert.equal(networkStatus.mainnet, 'degraded') |
||||||
// .catch(done)
|
}) |
||||||
//
|
}) |
||||||
// })
|
|
||||||
// })
|
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') |
||||||
|
}) |
||||||
|
}) |
||||||
|
}) |
||||||
|
}) |
||||||
|
Loading…
Reference in new issue