fix faulty null checks

feature/default_network_editable
Erik Marks 5 years ago
parent 1ae0933897
commit 0103bf8b29
No known key found for this signature in database
GPG Key ID: 11955E59BBB17134
  1. 3
      app/scripts/controllers/permissions/permissionsLog.js
  2. 2
      test/unit/app/controllers/transactions/tx-controller-test.js

@ -325,6 +325,7 @@ export default class PermissionsLogController {
getRequestedMethods (request) { getRequestedMethods (request) {
if ( if (
!request.params || !request.params ||
!request.params[0] ||
typeof request.params[0] !== 'object' || typeof request.params[0] !== 'object' ||
Array.isArray(request.params[0]) Array.isArray(request.params[0])
) { ) {
@ -392,7 +393,7 @@ function getLastIndexOfObjectArray (array, key, value) {
for (let i = array.length - 1; i >= 0; i--) { for (let i = array.length - 1; i >= 0; i--) {
if (typeof array[i] !== 'object') { if (!array[i] || typeof array[i] !== 'object') {
throw new Error(`Encountered non-Object element at index ${i}`) throw new Error(`Encountered non-Object element at index ${i}`)
} }

@ -57,7 +57,7 @@ describe('Transaction Controller', function () {
const exposedState = txController.getState() const exposedState = txController.getState()
assert('unapprovedTxs' in exposedState, 'state should have the key unapprovedTxs') assert('unapprovedTxs' in exposedState, 'state should have the key unapprovedTxs')
assert('selectedAddressTxList' in exposedState, 'state should have the key selectedAddressTxList') assert('selectedAddressTxList' in exposedState, 'state should have the key selectedAddressTxList')
assert(typeof exposedState.unapprovedTxs === 'object', 'should be an object') assert(exposedState && typeof exposedState.unapprovedTxs === 'object', 'should be an object')
assert(Array.isArray(exposedState.selectedAddressTxList), 'should be an array') assert(Array.isArray(exposedState.selectedAddressTxList), 'should be an array')
}) })
}) })

Loading…
Cancel
Save