Skip to content

Commit

Permalink
feat(ui): add tests for toggle header and bindings settings
Browse files Browse the repository at this point in the history
Co-authored-by: Jennifer Meyer <[email protected]>
Co-authored-by: Peter Zahn <[email protected]>
Co-authored-by: Christoph Volkert <[email protected]>
  • Loading branch information
4 people committed Nov 14, 2024
1 parent 316d569 commit 02388b2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
12 changes: 10 additions & 2 deletions springwolf-ui/src/app/components/header/header.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,21 @@ <h1 class="width-s-hide">{{ title }}</h1>
}
</mat-menu>

<button mat-menu-item (click)="toggleIsShowBindings()">
<button
mat-menu-item
(click)="toggleIsShowBindings()"
data-testid="settings-bindings"
>
<mat-icon>{{
isShowBindings ? "check_box" : "check_box_outline_blank"
}}</mat-icon>
Show bindings
</button>
<button mat-menu-item (click)="toggleIsShowHeaders()">
<button
mat-menu-item
(click)="toggleIsShowHeaders()"
data-testid="settings-headers"
>
<mat-icon>{{
isShowHeaders ? "check_box" : "check_box_outline_blank"
}}</mat-icon>
Expand Down
32 changes: 32 additions & 0 deletions springwolf-ui/src/app/components/header/header.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,36 @@ describe("HeaderComponent", () => {
fireEvent.click(screen.getByText("group1"));
expect(mockedUiService.changeGroup).toHaveBeenCalledWith("group1");
});

it("should trigger show bindings when clicked in settings menu", () => {
uiConfigSubject.next({
initialConfig: { showBindings: true, showHeaders: true },
groups: [{ name: "group1" }, { name: "group2" }],
});

// when clicking the checkbox
const settingButton = screen.getByTestId("settings");
fireEvent.click(settingButton);
const checkBox = screen.getByTestId("settings-bindings");
fireEvent.click(checkBox);

// then toggleIsShowBindings is called
expect(mockedUiService.toggleIsShowBindings).toBeCalled();
});

it("should trigger show headers when clicked in settings menu", () => {
uiConfigSubject.next({
initialConfig: { showBindings: true, showHeaders: true },
groups: [{ name: "group1" }, { name: "group2" }],
});

// when clicking the checkbox
const settingButton = screen.getByTestId("settings");
fireEvent.click(settingButton);
const checkBox = screen.getByTestId("settings-headers");
fireEvent.click(checkBox);

// then toggleIsShowHeaders is called
expect(mockedUiService.toggleIsShowHeaders).toBeCalled();
});
});

0 comments on commit 02388b2

Please sign in to comment.