From f2110938434d869d2f379197c758ba84d1d66383 Mon Sep 17 00:00:00 2001 From: Amal Sudama <cds.sudama@gmail.com> Date: Tue, 22 Jan 2019 13:29:24 -0500 Subject: [PATCH] run format --- src/blocks/blocksSaga.js | 7 +++++- src/contracts/contractsSaga.js | 6 +++++- src/web3/web3Saga.js | 6 +++--- test/accounts.test.js | 6 ++++-- test/contracts/create.test.js | 27 +++++++++++++++++++----- test/environments/ganache-environment.js | 7 +++--- test/utils/helpers.js | 8 +++++-- 7 files changed, 50 insertions(+), 17 deletions(-) diff --git a/src/blocks/blocksSaga.js b/src/blocks/blocksSaga.js index ed803dbf..6e34abc1 100644 --- a/src/blocks/blocksSaga.js +++ b/src/blocks/blocksSaga.js @@ -56,7 +56,12 @@ function * callCreateBlockChannel ({ drizzle, web3, syncAlways }) { * Poll for Blocks */ -export function createBlockPollChannel ({ drizzle, interval, web3, syncAlways }) { +export function createBlockPollChannel ({ + drizzle, + interval, + web3, + syncAlways +}) { return eventChannel(emit => { const blockTracker = new BlockTracker({ provider: web3.currentProvider, diff --git a/src/contracts/contractsSaga.js b/src/contracts/contractsSaga.js index b78853d9..961b9463 100644 --- a/src/contracts/contractsSaga.js +++ b/src/contracts/contractsSaga.js @@ -96,7 +96,11 @@ export function * instantiateContract ({ * Events */ -export function createContractEventChannel ({ contract, eventName, eventOptions }) { +export function createContractEventChannel ({ + contract, + eventName, + eventOptions +}) { const name = contract.contractName return eventChannel(emit => { diff --git a/src/web3/web3Saga.js b/src/web3/web3Saga.js index e3396dac..9e3aa882 100644 --- a/src/web3/web3Saga.js +++ b/src/web3/web3Saga.js @@ -7,7 +7,7 @@ var Web3 = require('web3') * Initialization */ -export function* initializeWeb3({ options }) { +export function * initializeWeb3 ({ options }) { try { var web3 = {} @@ -65,7 +65,7 @@ export function* initializeWeb3({ options }) { * Network ID */ -export function* getNetworkId({ web3 }) { +export function * getNetworkId ({ web3 }) { try { const networkId = yield call(web3.eth.net.getId) @@ -80,7 +80,7 @@ export function* getNetworkId({ web3 }) { } } -function* web3Saga() { +function * web3Saga () { yield takeLatest('NETWORK_ID_FETCHING', getNetworkId) } diff --git a/test/accounts.test.js b/test/accounts.test.js index f71418cc..40b33294 100644 --- a/test/accounts.test.js +++ b/test/accounts.test.js @@ -6,12 +6,14 @@ describe('Accounts Saga', () => { let web3, dispatchedActions, mockedStore beforeAll(() => { - [mockedStore, dispatchedActions] = mockDrizzleStore() + ;[mockedStore, dispatchedActions] = mockDrizzleStore() web3 = getWeb3() }) test('retrieves Metamask accounts', async () => { await runSaga(mockedStore, getAccounts, { web3 }).done - expect(dispatchedActions[0]['accounts']).toHaveLength(global.accounts.length) + expect(dispatchedActions[0]['accounts']).toHaveLength( + global.accounts.length + ) }) }) diff --git a/test/contracts/create.test.js b/test/contracts/create.test.js index 47f7cfc9..a9962772 100644 --- a/test/contracts/create.test.js +++ b/test/contracts/create.test.js @@ -14,8 +14,11 @@ describe('Creates a contract', () => { let mockedStore, web3, truffleArtifact, accounts beforeEach(async () => { - ({ web3, accounts, truffleArtifact } = await getWeb3Assets()) - ;[mockedStore] = mockDrizzleStore({ web3: { networkId: global.defaultNetworkId }, accounts }) + ;({ web3, accounts, truffleArtifact } = await getWeb3Assets()) + ;[mockedStore] = mockDrizzleStore({ + web3: { networkId: global.defaultNetworkId }, + accounts + }) }) test('with instantiateWeb3Contract Saga', async () => { @@ -31,10 +34,20 @@ describe('Creates a contract', () => { web3 } - const contractInstance = await runSaga(mockedStore, instantiateWeb3Contract, options).done + const contractInstance = await runSaga( + mockedStore, + instantiateWeb3Contract, + options + ).done expect(MockedDrizzleContract).toHaveBeenCalledTimes(1) - const expectedArgs = [mockedWeb3Contract, web3, mockedContractName, mockedStore, mockedContractEvents] + const expectedArgs = [ + mockedWeb3Contract, + web3, + mockedContractName, + mockedStore, + mockedContractEvents + ] expect(MockedDrizzleContract).toHaveBeenCalledWith(...expectedArgs) // It returns a Contract with the proper shape @@ -54,7 +67,11 @@ describe('Creates a contract', () => { const web3ContractCreator = jest.fn() web3.eth.Contract = web3ContractCreator - const contractInstance = await runSaga(mockedStore, instantiateContract, options).done + const contractInstance = await runSaga( + mockedStore, + instantiateContract, + options + ).done expect(web3ContractCreator).toHaveBeenCalledTimes(1) expect(MockedDrizzleContract).toHaveBeenCalledTimes(1) diff --git a/test/environments/ganache-environment.js b/test/environments/ganache-environment.js index ce7f467d..3a7874f8 100644 --- a/test/environments/ganache-environment.js +++ b/test/environments/ganache-environment.js @@ -3,7 +3,8 @@ const NodeEnvironment = require('jest-environment-node') const defaultSeed = 'drizzle' const defaultNetworkId = 6777 -const defaultAccounts = [ // based on default Mnemonic +const defaultAccounts = [ + // based on default Mnemonic '0x8aDB46251E9cd45b5027501766531825C04a2E06', '0xb50CF9eD8f60605bEbB967776925f21Ba5c81D5D', '0x7fC9AD8C7A3232Aed94d6C68728D22D722694824', @@ -17,7 +18,7 @@ const defaultAccounts = [ // based on default Mnemonic ] class GanacheEnvironment extends NodeEnvironment { - async setup() { + async setup () { await super.setup() // Startup a Ganache server. @@ -31,7 +32,7 @@ class GanacheEnvironment extends NodeEnvironment { this.global.defaultNetworkId = defaultNetworkId } - async teardown() { + async teardown () { // close provider engine gracefully this.global.provider.close(() => {}) await super.teardown() diff --git a/test/utils/helpers.js b/test/utils/helpers.js index 55fe45e9..c1619051 100644 --- a/test/utils/helpers.js +++ b/test/utils/helpers.js @@ -37,14 +37,18 @@ const getWeb3Assets = async () => { const accounts = await web3.eth.getAccounts() // use global.accounts? const instance = new web3.eth.Contract(abi) - const deployedByteCode = await instance.deploy({ data: byteCode.object }).send({ from: accounts[0], gas: 150000 }) + const deployedByteCode = await instance + .deploy({ data: byteCode.object }) + .send({ from: accounts[0], gas: 150000 }) const truffleArtifact = { contractName: 'TestContract', abi, byteCode, deployedByteCode, - networks: { [global.defaultNetworkId]: { address: deployedByteCode._address } } + networks: { + [global.defaultNetworkId]: { address: deployedByteCode._address } + } } return { web3, accounts, truffleArtifact }