38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
import { render, screen } from "@testing-library/react";
|
|
import userEvent from "@testing-library/user-event";
|
|
import { describe, expect, it, vi } from "vitest";
|
|
import { UploadWorkbench } from "../../src/components/UploadWorkbench";
|
|
|
|
vi.mock("../../src/components/OoxmlViewer", () => ({
|
|
OoxmlViewer: () => <section aria-label="Test OOXML viewer" />,
|
|
}));
|
|
|
|
describe("UploadWorkbench", () => {
|
|
it("exposes the initial local format families", () => {
|
|
render(<UploadWorkbench />);
|
|
|
|
expect(
|
|
screen.getByRole("heading", { name: "Open an office file" }),
|
|
).toBeInTheDocument();
|
|
for (const format of ["DOCX", "XLSX", "PPTX", "ODT", "ODS", "ODP"])
|
|
expect(screen.getByText(format)).toBeInTheDocument();
|
|
expect(screen.getByText("No upload")).toBeInTheDocument();
|
|
});
|
|
|
|
it("shows the identity of a locally selected file", async () => {
|
|
const user = userEvent.setup();
|
|
render(<UploadWorkbench />);
|
|
const input = screen.getByLabelText("Open office file");
|
|
const file = new File(["local fixture"], "report.docx", {
|
|
type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
});
|
|
|
|
await user.upload(input, file);
|
|
|
|
const heading = screen.getByRole("region", { name: "report.docx" });
|
|
expect(heading).toHaveTextContent("report.docx");
|
|
expect(heading).toHaveTextContent("13 B");
|
|
expect(screen.getByLabelText("Test OOXML viewer")).toBeInTheDocument();
|
|
});
|
|
});
|