Skip to content

Commit

Permalink
test: fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
okorie2 committed Nov 21, 2024
1 parent 677e11f commit f2ca343
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/app/modules/chart-module/__test__/filter.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const checkIfAllOptionsAreChecked = (options: FilterGroupOptionModel[]) => {
options.forEach((option: FilterGroupOptionModel) => {
expect(
screen.getByRole("checkbox", {
name: option.label,
name: option.label + " ()",
})
).toBeChecked();
if (option.subOptions && isOptionExpanded) {
Expand All @@ -118,7 +118,7 @@ const checkIfAllOptionsAreUnchecked = (options: FilterGroupOptionModel[]) => {
options.forEach((option: FilterGroupOptionModel) => {
expect(
screen.getByRole("checkbox", {
name: option.label,
name: option.label + " ()",
})
).not.toBeChecked();
if (option.subOptions && isOptionExpanded) {
Expand Down Expand Up @@ -354,14 +354,14 @@ test("search input should filter options", async () => {
expect(screen.getAllByTestId("filter-option-checkbox").length).toBe(5);
const filteredOptions = ["100", "1000", "10016", "10033", "1005"];
filteredOptions.forEach((option: string) => {
expect(screen.getByLabelText(option)).toBeInTheDocument();
expect(screen.getByLabelText(option + " ()")).toBeInTheDocument();
});

//delete search input
await user.clear(searchInput);
expect(screen.getAllByTestId("filter-option-checkbox").length).toBe(3);
props.options.forEach((option: any) => {
expect(screen.getByLabelText(option.label)).toBeInTheDocument();
expect(screen.getByLabelText(option.label + " ()")).toBeInTheDocument();
});
});

Expand All @@ -380,7 +380,9 @@ test("should multi check and uncheck filter options", async () => {
render(app);
const checkboxList: HTMLElement[] = [];
props.options.forEach((option: any) => {
checkboxList.push(screen.getByRole("checkbox", { name: option.label }));
checkboxList.push(
screen.getByRole("checkbox", { name: option.label + " ()" })
);
});
expect(checkboxList.length).toBe(3);
//multi check filte options
Expand Down

0 comments on commit f2ca343

Please sign in to comment.