Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit 75e163c

Browse files
committed
tests
1 parent b84b13d commit 75e163c

4 files changed

Lines changed: 19 additions & 4 deletions

File tree

webview-ui/src/components/settings/__tests__/SettingsView.change-detection.spec.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ vi.mock("@src/i18n/TranslationContext", () => ({
2828

2929
// Mock UI components
3030
vi.mock("@src/components/ui", () => ({
31+
ToggleSwitch: ({ checked, onChange, "aria-label": ariaLabel, "data-testid": dataTestId }: any) => (
32+
<button role="switch" aria-checked={checked} aria-label={ariaLabel} data-testid={dataTestId} onClick={onChange}>
33+
Toggle
34+
</button>
35+
),
3136
AlertDialog: ({ open, children }: any) => (open ? <div data-testid="alert-dialog">{children}</div> : null),
3237
AlertDialogContent: ({ children }: any) => <div>{children}</div>,
3338
AlertDialogTitle: ({ children }: any) => <div data-testid="alert-title">{children}</div>,

webview-ui/src/components/settings/__tests__/SettingsView.spec.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ vi.mock("../../../components/common/Tab", () => ({
116116

117117
vi.mock("@/components/ui", () => ({
118118
...vi.importActual("@/components/ui"),
119+
ToggleSwitch: ({ checked, onChange, "aria-label": ariaLabel, "data-testid": dataTestId }: any) => (
120+
<button role="switch" aria-checked={checked} aria-label={ariaLabel} data-testid={dataTestId} onClick={onChange}>
121+
Toggle
122+
</button>
123+
),
119124
Popover: ({ children }: any) => <div data-testid="popover">{children}</div>,
120125
PopoverTrigger: ({ children }: any) => <div data-testid="popover-trigger">{children}</div>,
121126
PopoverContent: ({ children }: any) => <div data-testid="popover-content">{children}</div>,

webview-ui/src/components/settings/__tests__/SettingsView.unsaved-changes.spec.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ vi.mock("@src/i18n/TranslationContext", () => ({
2929

3030
// Mock UI components
3131
vi.mock("@src/components/ui", () => ({
32+
ToggleSwitch: ({ checked, onChange, "aria-label": ariaLabel, "data-testid": dataTestId }: any) => (
33+
<button role="switch" aria-checked={checked} aria-label={ariaLabel} data-testid={dataTestId} onClick={onChange}>
34+
Toggle
35+
</button>
36+
),
3237
AlertDialog: ({ children }: any) => <div>{children}</div>,
3338
AlertDialogContent: ({ children }: any) => <div>{children}</div>,
3439
AlertDialogTitle: ({ children }: any) => <div>{children}</div>,

webview-ui/src/components/ui/__tests__/toggle-switch.spec.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ describe("ToggleSwitch", () => {
8585

8686
const toggle = screen.getByRole("switch")
8787
expect(toggle).toBeInTheDocument()
88-
// Medium size should be 20px x 10px
89-
expect(toggle).toHaveStyle({ width: "20px", height: "10px" })
88+
// Medium size should be 26px x 10px
89+
expect(toggle).toHaveStyle({ width: "26px", height: "10px" })
9090
})
9191

9292
it("defaults to small size", () => {
@@ -95,7 +95,7 @@ describe("ToggleSwitch", () => {
9595

9696
const toggle = screen.getByRole("switch")
9797
expect(toggle).toBeInTheDocument()
98-
// Small size should be 16px x 8px
99-
expect(toggle).toHaveStyle({ width: "16px", height: "8px" })
98+
// Small size should be 20px x 10px
99+
expect(toggle).toHaveStyle({ width: "20px", height: "10px" })
100100
})
101101
})

0 commit comments

Comments
 (0)