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", () => ({
|
vi.mock("react-syntax-highlighter/dist/esm/prism-async-light", () => ({
|
||||||
default: ({
|
default: ({
|
||||||
children,
|
children,
|
||||||
|
language,
|
||||||
style,
|
style,
|
||||||
}: {
|
}: {
|
||||||
children: string;
|
children: string;
|
||||||
|
language?: string;
|
||||||
style: Record<string, unknown>;
|
style: Record<string, unknown>;
|
||||||
}) => (
|
}) => (
|
||||||
<pre
|
<pre
|
||||||
data-testid="highlighted-code"
|
data-testid="highlighted-code"
|
||||||
|
data-language={language}
|
||||||
data-theme={style === mockedStyles.dark ? "dark" : "light"}
|
data-theme={style === mockedStyles.dark ? "dark" : "light"}
|
||||||
>
|
>
|
||||||
<code>{children}</code>
|
<code>{children}</code>
|
||||||
@ -61,6 +64,7 @@ describe("CodeBlock", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(screen.getByTestId("highlighted-code")).toBeInTheDocument();
|
expect(screen.getByTestId("highlighted-code")).toBeInTheDocument();
|
||||||
|
expect(screen.getByTestId("highlighted-code")).toHaveAttribute("data-language", "text");
|
||||||
expect(screen.getByText("const value = 1;")).toBeInTheDocument();
|
expect(screen.getByText("const value = 1;")).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -24,6 +24,7 @@ describe("MarkdownTextRenderer", () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
expect(screen.getByText("code without language")).toBeInTheDocument();
|
expect(screen.getByText("code without language")).toBeInTheDocument();
|
||||||
|
expect(screen.getByText("text")).toBeInTheDocument();
|
||||||
expect(container.querySelectorAll("pre")).toHaveLength(1);
|
expect(container.querySelectorAll("pre")).toHaveLength(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user