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:
Zoran Joka 2018-11-08 09:24:09 +01:00 committed by Josh Harvey
parent d97a33565f
commit 599c865f37
2 changed files with 43 additions and 1 deletions

View file

@ -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
}