diff --git a/packages/core-utils/src/__tests__/query-params.ts b/packages/core-utils/src/__tests__/query-params.ts index 4ca38ac77..4c21beb36 100644 --- a/packages/core-utils/src/__tests__/query-params.ts +++ b/packages/core-utils/src/__tests__/query-params.ts @@ -70,6 +70,16 @@ describe("extract-modes", () => { value: true }; + const checkboxModeSettingWithModeArray: ModeSetting = { + addTransportMode: [mode, mode], + applicableMode: testTransportMode.mode, + icon: null, + key: "test", + label: "test", + type: "CHECKBOX", + value: true + }; + const dropdownModeSetting: ModeSetting = { applicableMode: testTransportMode.mode, key: "test", @@ -84,6 +94,14 @@ describe("extract-modes", () => { extractAdditionalModes([checkboxModeSetting], [testTransportMode]) ).toEqual([mode]); }); + it("determines whether a checkbox setting with an array of modes is extracted correctly", () => { + expect( + extractAdditionalModes( + [checkboxModeSettingWithModeArray], + [testTransportMode] + ) + ).toEqual([mode, mode]); + }); it("determines whether a dropdown setting is extracted correctly", () => { expect( extractAdditionalModes([dropdownModeSetting], [testTransportMode]) diff --git a/packages/core-utils/src/query-gen.ts b/packages/core-utils/src/query-gen.ts index 14f989701..b0a3655d1 100644 --- a/packages/core-utils/src/query-gen.ts +++ b/packages/core-utils/src/query-gen.ts @@ -63,7 +63,10 @@ export function extractAdditionalModes( cur.addTransportMode && cur.value ) { - return [...prev, cur.addTransportMode]; + const { addTransportMode } = cur; + return Array.isArray(addTransportMode) + ? [...prev, ...addTransportMode] + : [...prev, addTransportMode]; } if (cur.type === "DROPDOWN") { const transportMode = cur.options.find(o => o.value === cur.value) diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 1aed84d6e..a5c88fa0c 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -707,7 +707,7 @@ export type SliderOptions = { }; export type CheckboxOptions = { - addTransportMode?: TransportMode; + addTransportMode?: TransportMode | TransportMode[]; default?: boolean; label: string; type: "CHECKBOX";