1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-27 21:00:13 +01:00
metamask-extension/test/unit/app/controllers/infura-controller-test.js

63 lines
1.8 KiB
JavaScript
Raw Normal View History

2017-07-14 19:34:03 +02:00
const assert = require('assert')
2017-07-14 22:06:42 +02:00
const sinon = require('sinon')
const InfuraController = require('../../../../app/scripts/controllers/infura')
2017-07-14 19:34:03 +02:00
describe('infura-controller', function () {
2017-07-14 22:06:42 +02:00
let infuraController, sandbox, networkStatus
const response = {'mainnet': 'degraded', 'ropsten': 'ok', 'kovan': 'ok', 'rinkeby': 'down'}
2017-07-14 19:34:03 +02:00
before(async function () {
infuraController = new InfuraController()
sandbox = sinon.createSandbox()
2017-07-14 22:06:42 +02:00
sinon.stub(infuraController, 'checkInfuraNetworkStatus').resolves(response)
networkStatus = await infuraController.checkInfuraNetworkStatus()
})
after(function () {
sandbox.restore()
2017-07-14 19:34:03 +02:00
})
describe('Network status queries', function () {
describe('Mainnet', function () {
it('should have Mainnet', function () {
2017-07-14 22:06:42 +02:00
assert.equal(Object.keys(networkStatus)[0], 'mainnet')
2017-07-14 19:34:03 +02:00
})
it('should have a value for Mainnet status', function () {
2017-07-14 22:06:42 +02:00
assert.equal(networkStatus.mainnet, 'degraded')
2017-07-14 19:34:03 +02:00
})
})
describe('Ropsten', function () {
it('should have Ropsten', function () {
2017-07-14 22:06:42 +02:00
assert.equal(Object.keys(networkStatus)[1], 'ropsten')
2017-07-14 19:34:03 +02:00
})
it('should have a value for Ropsten status', function () {
2017-07-14 22:06:42 +02:00
assert.equal(networkStatus.ropsten, 'ok')
2017-07-14 19:34:03 +02:00
})
})
describe('Kovan', function () {
it('should have Kovan', function () {
2017-07-14 22:06:42 +02:00
assert.equal(Object.keys(networkStatus)[2], 'kovan')
2017-07-14 19:34:03 +02:00
})
it('should have a value for Kovan status', function () {
2017-07-14 22:06:42 +02:00
assert.equal(networkStatus.kovan, 'ok')
2017-07-14 19:34:03 +02:00
})
})
describe('Rinkeby', function () {
it('should have Rinkeby', function () {
2017-07-14 22:06:42 +02:00
assert.equal(Object.keys(networkStatus)[3], 'rinkeby')
2017-07-14 19:34:03 +02:00
})
it('should have a value for Rinkeby status', function () {
2017-07-14 22:06:42 +02:00
assert.equal(networkStatus.rinkeby, 'down')
2017-07-14 19:34:03 +02:00
})
})
})
})