Filter only mock options when in dev mode (#206)
* Filter only mock options when in dev mode * Filter only in production mode * Refactor filter to separate function, add unit tests * Check for mock codes in test
This commit is contained in:
parent
d97a33565f
commit
599c865f37
2 changed files with 43 additions and 1 deletions
|
|
@ -1,4 +1,5 @@
|
|||
const _ = require('lodash/fp')
|
||||
const devMode = require('minimist')(process.argv.slice(2)).dev
|
||||
|
||||
const currencies = require('../../currencies.json')
|
||||
const languageRec = require('../../languages.json')
|
||||
|
|
@ -153,6 +154,12 @@ const supportedLanguages = languageRec.supported
|
|||
const languages = supportedLanguages.map(mapLanguage).filter(r => r)
|
||||
const ALL_CRYPTOS = ['BTC', 'ETH', 'LTC', 'DASH', 'ZEC', 'BCH']
|
||||
|
||||
const filterAccounts = (data, isDevMode) => {
|
||||
const notAllowed = ['mock-ticker', 'mock-wallet', 'mock-exchange', 'mock-sms', 'mock-id-verify', 'mock-zero-conf']
|
||||
const filterOut = o => _.includes(o.code, notAllowed)
|
||||
return isDevMode ? data : {...data, accounts: _.filter(a => !filterOut(a), data.accounts)}
|
||||
}
|
||||
|
||||
function fetchData () {
|
||||
return machineLoader.getMachineNames()
|
||||
.then(machineList => ({
|
||||
|
|
@ -200,6 +207,9 @@ function fetchData () {
|
|||
],
|
||||
machines: machineList.map(machine => ({machine: machine.deviceId, display: machine.name}))
|
||||
}))
|
||||
.then((data) => {
|
||||
return filterAccounts(data, devMode)
|
||||
})
|
||||
}
|
||||
|
||||
function saveConfigGroup (results) {
|
||||
|
|
@ -213,5 +223,6 @@ module.exports = {
|
|||
fetchConfigGroup,
|
||||
saveConfigGroup,
|
||||
validateCurrentConfig,
|
||||
fetchConfig
|
||||
fetchConfig,
|
||||
filterAccounts
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue