Skip to content

Commit bce1f12

Browse files
committed
fix: missing test for CodeAccordion
1 parent d23d4a6 commit bce1f12

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

‎webview-ui/src/components/common/__tests__/CodeAccordion.spec.tsx‎

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,16 @@ import CodeAccordion from "../CodeAccordion"
44

55
vi.mock("@src/i18n/TranslationContext", () => ({
66
useAppTranslation: () => ({
7-
t: (key: string, options?: Record<string, unknown>) =>
8-
key === "chat:codeAccordion.openFileAriaLabel" ? `${key} ${JSON.stringify(options)}` : key,
7+
t: (key: string, options?: Record<string, unknown>) => {
8+
const translations: Record<string, string> = {
9+
"chat:codeAccordion.userEdits": "User Edits",
10+
"chat:codeAccordion.consoleLogs": "Console Logs",
11+
}
12+
return (
13+
translations[key] ??
14+
(key === "chat:codeAccordion.openFileAriaLabel" ? `${key} ${JSON.stringify(options)}` : key)
15+
)
16+
},
917
}),
1018
}))
1119

@@ -30,4 +38,18 @@ describe("CodeAccordion", () => {
3038
screen.getByLabelText(`chat:codeAccordion.openFileAriaLabel ${JSON.stringify({ path: "src/example.ts" })}`),
3139
).toBeInTheDocument()
3240
})
41+
42+
it("renders the translated user-edits label for feedback", () => {
43+
render(
44+
<CodeAccordion
45+
code="const x = 1"
46+
language="typescript"
47+
isExpanded={false}
48+
isFeedback={true}
49+
onToggleExpand={() => {}}
50+
/>,
51+
)
52+
53+
expect(screen.getByText("User Edits")).toBeInTheDocument()
54+
})
3355
})

0 commit comments

Comments
 (0)