mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
throw if 0 products enabled 💥
This should have been the case previously, but the test didn't fail.
This commit is contained in:
parent
634b044bc5
commit
a356a26e2f
1 changed files with 3 additions and 1 deletions
|
@ -16,12 +16,14 @@ const createFormatProductsFilter = (profile) => {
|
|||
if (!isObj(filter)) throw new Error('products filter must be an object')
|
||||
filter = Object.assign({}, defaultProducts, filter)
|
||||
|
||||
let res = 0
|
||||
let res = 0, products = 0
|
||||
for (let product in filter) {
|
||||
if (!hasProp(filter, product) || filter[product] !== true) continue
|
||||
if (!byProduct[product]) throw new Error('unknown product ' + product)
|
||||
products++
|
||||
for (let bitmask of byProduct[product].bitmasks) res += bitmask
|
||||
}
|
||||
if (products === 0) throw new Error('no products used')
|
||||
|
||||
return {
|
||||
type: 'PROD',
|
||||
|
|
Loading…
Add table
Reference in a new issue