Skip to content

Commit

Permalink
improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
yhabib committed Dec 18, 2024
1 parent 581b2a0 commit eb53247
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ describe("ReportingDateRangeSelector", () => {
return { po, component };
};

const getValueFromComponent = (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" });

Expand Down Expand Up @@ -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 = getValueFromComponent(component, "period");
expect(currentValue).toBe("all");

await allOptions[1].click();
await tick();

const currentValue = component.$$.ctx[component.$$.props["period"]];
currentValue = getValueFromComponent(component, "period");
expect(currentValue).toBe("last-year");
});
});

0 comments on commit eb53247

Please sign in to comment.