From df5db9df706279498fa9a718a00fe2881276e066 Mon Sep 17 00:00:00 2001 From: Bartosz Prusinowski Date: Mon, 4 Dec 2023 16:11:25 +0100 Subject: [PATCH] chore: Add joinBy-based filtering by mapping status unit test --- app/configurator/configurator-state.spec.tsx | 35 ++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/app/configurator/configurator-state.spec.tsx b/app/configurator/configurator-state.spec.tsx index dcf6e611a..9fde5d0b2 100644 --- a/app/configurator/configurator-state.spec.tsx +++ b/app/configurator/configurator-state.spec.tsx @@ -6,6 +6,7 @@ import { ChartConfig, ChartType, ColumnConfig, + ComboLineDualConfig, ConfiguratorStateConfiguringChart, DataSource, Filters, @@ -820,6 +821,40 @@ describe("getFiltersByMappingStatus", () => { expect.arrayContaining(["areaColorIri", "symbolColorIri"]) ); }); + + it("should correctly retrieve filters when using joinBy dimension", () => { + const config = { + chartType: "line-dual", + cubes: [ + { + iri: "fo1", + filters: {}, + joinBy: "X1", + }, + { + iri: "foo2", + filters: {}, + joinBy: "X2", + }, + ], + fields: { + x: { + componentIri: "joinBy", + }, + }, + } as any as ComboLineDualConfig; + + const { mappedFiltersIris } = getFiltersByMappingStatus(config, { + cubeIri: "foo", + joinByIris: ["X1", "X2"], + }); + + // If the joinBy dimensions are treated as being mapped, we won't apply + // single filters to them when deriving filters from fields. + expect([...mappedFiltersIris]).toEqual( + expect.arrayContaining(["X1", "X2"]) + ); + }); }); describe("colorMapping", () => {