From 34b503e02241c4014ba085d911c15e5dac4ad5ea Mon Sep 17 00:00:00 2001 From: Yusef Habib Fernandez Date: Wed, 18 Dec 2024 21:17:17 +0100 Subject: [PATCH] fixes --- .../reporting/ReportingDateRangeSelector.spec.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/frontend/src/tests/lib/components/reporting/ReportingDateRangeSelector.spec.ts b/frontend/src/tests/lib/components/reporting/ReportingDateRangeSelector.spec.ts index eee9740281b..887a1a575f0 100644 --- a/frontend/src/tests/lib/components/reporting/ReportingDateRangeSelector.spec.ts +++ b/frontend/src/tests/lib/components/reporting/ReportingDateRangeSelector.spec.ts @@ -24,6 +24,10 @@ describe("ReportingDateRangeSelector", () => { return { po, component }; }; + const getComponentPropValue = (component, propName: string) => { + return component.$$.ctx[component.$$.props[propName]]; + }; + it("should render the option provided as a prop", async () => { const { po } = renderComponent({ period: "last-year" }); @@ -64,12 +68,13 @@ describe("ReportingDateRangeSelector", () => { const { po, component } = renderComponent(); const allOptions = await po.getAllOptions(); - // Click the second option - await allOptions[1].click(); + let currentValue = getComponentPropValue(component, "period"); + expect(currentValue).toBe("all"); + await allOptions[1].click(); await tick(); - const currentValue = component.$$.ctx[component.$$.props["period"]]; + currentValue = getComponentPropValue(component, "period"); expect(currentValue).toBe("last-year"); }); });