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

73 lines
2.1 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
2019-12-03 21:50:55 +01:00
const response = { 'mainnet': 'degraded', 'ropsten': 'ok', 'kovan': 'ok', 'rinkeby': 'down', 'goerli': 'ok' }
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
})
})
2019-04-17 19:34:49 +02:00
describe('Goerli', function () {
it('should have Goerli', function () {
assert.equal(Object.keys(networkStatus)[4], 'goerli')
})
it('should have a value for Goerli status', function () {
assert.equal(networkStatus.goerli, 'ok')
})
})
2017-07-14 19:34:03 +02:00
})
})