HF / console /src /pages /Coding /FilePreview.test.tsx
mysticaldragon's picture
Deploy QwenPaw - Personal AI Assistant Platform
4e7644b
Raw History Blame Contribute Delete
1.26 kB
import { render, screen, within } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import FilePreview from "./FilePreview";
describe("FilePreview", () => {
it("shows YAML frontmatter as metadata while preserving the body", () => {
render(
<FilePreview
filePath="memory-search.md"
content={[
"---",
"description: Memory Search query guidance",
"name: memory-search-query-best-practices",
"---",
"",
"## When to Use",
"",
"Use this when searching memory.",
].join("\n")}
/>,
);
const frontmatter = within(screen.getByLabelText("Front matter"));
expect(frontmatter.getByText("description")).toBeInTheDocument();
expect(
frontmatter.getByText("Memory Search query guidance"),
).toBeInTheDocument();
expect(frontmatter.getByText("name")).toBeInTheDocument();
expect(
frontmatter.getByText("memory-search-query-best-practices"),
).toBeInTheDocument();
expect(
screen.getByRole("heading", { level: 2, name: "When to Use" }),
).toBeInTheDocument();
expect(
screen.getByText("Use this when searching memory."),
).toBeInTheDocument();
});
});