aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Huang <thomas.b.huang@gmail.com>2018-02-16 01:54:22 +0800
committerThomas Huang <thomas.b.huang@gmail.com>2018-02-16 01:54:22 +0800
commit8f7094a73d4ca5879e8290e3b1aefdc42397767d (patch)
tree0a48845bd31985af36ed5bd6012e07e079b35dd4
parent33182efb1384dc05c8ecdb8994d12dd30abcbc7e (diff)
downloadtangerine-wallet-browser-8f7094a73d4ca5879e8290e3b1aefdc42397767d.tar
tangerine-wallet-browser-8f7094a73d4ca5879e8290e3b1aefdc42397767d.tar.gz
tangerine-wallet-browser-8f7094a73d4ca5879e8290e3b1aefdc42397767d.tar.bz2
tangerine-wallet-browser-8f7094a73d4ca5879e8290e3b1aefdc42397767d.tar.lz
tangerine-wallet-browser-8f7094a73d4ca5879e8290e3b1aefdc42397767d.tar.xz
tangerine-wallet-browser-8f7094a73d4ca5879e8290e3b1aefdc42397767d.tar.zst
tangerine-wallet-browser-8f7094a73d4ca5879e8290e3b1aefdc42397767d.zip
Network controller nock
-rw-r--r--test/unit/network-contoller-test.js40
1 files changed, 16 insertions, 24 deletions
diff --git a/test/unit/network-contoller-test.js b/test/unit/network-contoller-test.js
index fe3b9e66a..cd8c345c5 100644
--- a/test/unit/network-contoller-test.js
+++ b/test/unit/network-contoller-test.js
@@ -2,28 +2,37 @@ 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: () => {},
}
beforeEach(function () {
+
nock('https://api.infura.io')
.get('/*/')
- .reply(200, {})
+ .reply(200)
+
+ nock('https://rinkeby.infura.io')
+ .post('/metamask')
+ .reply(200)
+
networkController = new NetworkController({
- provider: {
- type: 'rinkeby',
- },
+ provider,
})
- networkController.initializeProvider(networkControllerProviderInit, dummyProviderConstructor)
+ networkController.initializeProvider(networkControllerProviderInit, provider)
})
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)
@@ -68,21 +77,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