mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Add test for infura controller.
This commit is contained in:
parent
f9f0f6f9ef
commit
199663c0a4
34
test/unit/infura-controller-test.js
Normal file
34
test/unit/infura-controller-test.js
Normal file
@ -0,0 +1,34 @@
|
||||
// polyfill fetch
|
||||
global.fetch = global.fetch || require('isomorphic-fetch')
|
||||
|
||||
const assert = require('assert')
|
||||
const nock = require('nock')
|
||||
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 () {
|
||||
this.timeout(15000)
|
||||
nock('https://api.infura.io')
|
||||
.get('/v1/status/metamask')
|
||||
.reply(200, '{"mainnet": "ok", "ropsten": "degraded", "kovan": "down", "rinkeby": "ok"}')
|
||||
|
||||
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')
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue
Block a user