2017-06-22 21:51:53 +02:00
|
|
|
// polyfill fetch
|
2017-06-22 22:58:55 +02:00
|
|
|
global.fetch = function () {return Promise.resolve({
|
2017-06-22 22:46:08 +02:00
|
|
|
json: () => { return Promise.resolve({"mainnet": "ok", "ropsten": "degraded", "kovan": "down", "rinkeby": "ok"}) },
|
|
|
|
})
|
|
|
|
}
|
2017-06-22 21:51:53 +02:00
|
|
|
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 () {
|
2017-06-22 22:46:08 +02:00
|
|
|
it('should return an object reflecting the network statuses', function (done) {
|
2017-06-22 21:51:53 +02:00
|
|
|
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')
|
|
|
|
})
|
2017-06-22 22:46:08 +02:00
|
|
|
.then(() => done())
|
|
|
|
.catch(done)
|
|
|
|
|
2017-06-22 21:51:53 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|