diff options
Diffstat (limited to 'test/unit/network-contoller-test.js')
-rw-r--r-- | test/unit/network-contoller-test.js | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/test/unit/network-contoller-test.js b/test/unit/network-contoller-test.js index 0b3b5adeb..dd0b52365 100644 --- a/test/unit/network-contoller-test.js +++ b/test/unit/network-contoller-test.js @@ -1,25 +1,40 @@ const assert = require('assert') +const nock = require('nock') const NetworkController = require('../../app/scripts/controllers/network') +const { createTestProviderTools } = require('../stub/provider') +const providerResultStub = {} +const provider = createTestProviderTools({ scaffold: providerResultStub }).provider + describe('# Network Controller', function () { let networkController + const noop = () => {} const networkControllerProviderInit = { - getAccounts: () => {}, + getAccounts: noop, } beforeEach(function () { + + nock('https://rinkeby.infura.io') + .persist() + .post('/metamask') + .reply(200) + networkController = new NetworkController({ - provider: { - type: 'rinkeby', - }, + provider, }) - networkController.initializeProvider(networkControllerProviderInit, dummyProviderConstructor) + networkController.initializeProvider(networkControllerProviderInit, provider) + }) + + afterEach(function () { + nock.cleanAll() }) + describe('network', function () { describe('#provider', function () { it('provider should be updatable without reassignment', function () { - networkController.initializeProvider(networkControllerProviderInit, dummyProviderConstructor) + networkController.initializeProvider(networkControllerProviderInit, provider) const proxy = networkController._proxy proxy.setTarget({ test: true, on: () => {} }) assert.ok(proxy.test) @@ -64,21 +79,4 @@ describe('# Network Controller', function () { }) }) }) -}) - -function dummyProviderConstructor() { - return { - // provider - sendAsync: noop, - // block tracker - _blockTracker: {}, - start: noop, - stop: noop, - on: noop, - addListener: noop, - once: noop, - removeAllListeners: noop, - } -} - -function noop() {}
\ No newline at end of file +})
\ No newline at end of file |