mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-06-13 14:23:58 +00:00
test(webui): assert code block language fallback
This commit is contained in:
parent
bdb3a2ded7
commit
15c6abc991
@ -12,13 +12,16 @@ const mockedStyles = vi.hoisted(() => ({
|
||||
vi.mock("react-syntax-highlighter/dist/esm/prism-async-light", () => ({
|
||||
default: ({
|
||||
children,
|
||||
language,
|
||||
style,
|
||||
}: {
|
||||
children: string;
|
||||
language?: string;
|
||||
style: Record<string, unknown>;
|
||||
}) => (
|
||||
<pre
|
||||
data-testid="highlighted-code"
|
||||
data-language={language}
|
||||
data-theme={style === mockedStyles.dark ? "dark" : "light"}
|
||||
>
|
||||
<code>{children}</code>
|
||||
@ -61,6 +64,7 @@ describe("CodeBlock", () => {
|
||||
});
|
||||
|
||||
expect(screen.getByTestId("highlighted-code")).toBeInTheDocument();
|
||||
expect(screen.getByTestId("highlighted-code")).toHaveAttribute("data-language", "text");
|
||||
expect(screen.getByText("const value = 1;")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
||||
@ -24,6 +24,7 @@ describe("MarkdownTextRenderer", () => {
|
||||
);
|
||||
|
||||
expect(screen.getByText("code without language")).toBeInTheDocument();
|
||||
expect(screen.getByText("text")).toBeInTheDocument();
|
||||
expect(container.querySelectorAll("pre")).toHaveLength(1);
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user