diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 3a7e2a489ef8..b610bd171a53 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -398,7 +398,7 @@ class PreferencesController { * @returns {Promise} Promise resolving to updated frequentRpcList. * */ - addToFrequentRpcList (url, chainId, ticker, nickname) { + addToFrequentRpcList (url, chainId, ticker = 'ETH', nickname = '') { const rpcList = this.getFrequentRpcListDetail() const index = rpcList.findIndex((element) => { return element.rpcUrl === url }) if (index !== -1) { diff --git a/test/unit/app/controllers/preferences-controller-test.js b/test/unit/app/controllers/preferences-controller-test.js index 7f2804a83588..c64c47ae9834 100644 --- a/test/unit/app/controllers/preferences-controller-test.js +++ b/test/unit/app/controllers/preferences-controller-test.js @@ -487,20 +487,20 @@ describe('preferences controller', function () { describe('on updateFrequentRpcList', function () { it('should add custom RPC url to state', function () { - preferencesController.addToFrequentRpcList('rpc_url') - preferencesController.addToFrequentRpcList('http://localhost:8545') - assert.deepEqual(preferencesController.store.getState().frequentRpcList, ['rpc_url']) - preferencesController.addToFrequentRpcList('rpc_url') - assert.deepEqual(preferencesController.store.getState().frequentRpcList, ['rpc_url']) + preferencesController.addToFrequentRpcList('rpc_url', 1) + preferencesController.addToFrequentRpcList('http://localhost:8545', 1) + assert.deepEqual(preferencesController.store.getState().frequentRpcListDetail, [{ rpcUrl: 'rpc_url', chainId: 1, ticker: 'ETH', nickname: '' }] ) + preferencesController.addToFrequentRpcList('rpc_url', 1) + assert.deepEqual(preferencesController.store.getState().frequentRpcListDetail, [{ rpcUrl: 'rpc_url', chainId: 1, ticker: 'ETH', nickname: '' }] ) }) it('should remove custom RPC url from state', function () { - preferencesController.addToFrequentRpcList('rpc_url') - assert.deepEqual(preferencesController.store.getState().frequentRpcList, ['rpc_url']) + preferencesController.addToFrequentRpcList('rpc_url', 1) + assert.deepEqual(preferencesController.store.getState().frequentRpcListDetail, [{ rpcUrl: 'rpc_url', chainId: 1, ticker: 'ETH', nickname: '' }] ) preferencesController.removeFromFrequentRpcList('other_rpc_url') preferencesController.removeFromFrequentRpcList('http://localhost:8545') preferencesController.removeFromFrequentRpcList('rpc_url') - assert.deepEqual(preferencesController.store.getState().frequentRpcList, []) + assert.deepEqual(preferencesController.store.getState().frequentRpcListDetail, []) }) }) }) diff --git a/ui/app/components/user-preferenced-currency-display/tests/user-preferenced-currency-display.container.test.js b/ui/app/components/user-preferenced-currency-display/tests/user-preferenced-currency-display.container.test.js index d017b6168ba4..00a6079f4ca2 100644 --- a/ui/app/components/user-preferenced-currency-display/tests/user-preferenced-currency-display.container.test.js +++ b/ui/app/components/user-preferenced-currency-display/tests/user-preferenced-currency-display.container.test.js @@ -40,12 +40,14 @@ describe('UserPreferencedCurrencyDisplay container', () => { { stateProps: { useETHAsPrimaryCurrency: true, + fromCurrency: 'ETH', }, ownProps: { type: 'PRIMARY', }, result: { currency: 'ETH', + fromCurrency: 'ETH', numberOfDecimals: 6, prefix: undefined, }, @@ -53,12 +55,14 @@ describe('UserPreferencedCurrencyDisplay container', () => { { stateProps: { useETHAsPrimaryCurrency: false, + fromCurrency: 'ETH', }, ownProps: { type: 'PRIMARY', }, result: { currency: undefined, + fromCurrency: 'ETH', numberOfDecimals: 2, prefix: undefined, }, @@ -66,6 +70,7 @@ describe('UserPreferencedCurrencyDisplay container', () => { { stateProps: { useETHAsPrimaryCurrency: true, + fromCurrency: 'ETH', }, ownProps: { type: 'SECONDARY', @@ -73,6 +78,7 @@ describe('UserPreferencedCurrencyDisplay container', () => { fiatPrefix: '-', }, result: { + fromCurrency: 'ETH', currency: undefined, numberOfDecimals: 4, prefix: '-', @@ -81,6 +87,7 @@ describe('UserPreferencedCurrencyDisplay container', () => { { stateProps: { useETHAsPrimaryCurrency: false, + fromCurrency: 'ETH', }, ownProps: { type: 'SECONDARY', @@ -91,6 +98,7 @@ describe('UserPreferencedCurrencyDisplay container', () => { }, result: { currency: 'ETH', + fromCurrency: 'ETH', numberOfDecimals: 3, prefix: 'b', },