1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-30 16:18:07 +01:00
metamask-extension/test/unit/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')
2017-07-14 19:34:03 +02:00
const InfuraController = require('../../app/scripts/controllers/infura')
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()
2017-07-14 22:06:42 +02:00
sandbox = sinon.sandbox.create()
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
})
})
})
})