Files
epub-tools/tests/components/app.test.tsx
T
zemion efd80eb18a
Verify / verify (push) Canceled after 0s
Release EPUB Tools 0.2.0
2026-09-02 08:53:49 +02:00

54 lines
1.5 KiB
TypeScript

import { fireEvent, render, screen } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import { App } from "../../src/App";
describe("EPUB Tools", () => {
it("renders the local workbench and standard shell", async () => {
vi.stubGlobal(
"fetch",
vi.fn(async () => new Response("Not found", { status: 404 })),
);
render(<App />);
expect(
await screen.findByRole("heading", { name: "EPUB Tools" }),
).toBeVisible();
expect(
await screen.findByText("Sandboxed reader · local files", undefined, {
timeout: 4_000,
}),
).toBeVisible();
});
it("shows the selected filename and progress before archive work starts", async () => {
vi.stubGlobal(
"fetch",
vi.fn(async () => new Response("Not found", { status: 404 })),
);
vi.stubGlobal(
"requestAnimationFrame",
vi.fn(() => 1),
);
render(<App />);
const input = await screen.findByLabelText(
"Choose publication",
undefined,
{ timeout: 4_000 },
);
fireEvent.change(input, {
target: {
files: [
new File(["not read yet"], "large-publication.epub", {
type: "application/epub+zip",
}),
],
},
});
const status = await screen.findByRole("status");
expect(status).toHaveTextContent("large-publication.epub");
expect(status).toHaveTextContent("Preparing the local file");
expect(
screen.getByRole("progressbar", { name: "EPUB opening progress" }),
).toHaveValue(0);
});
});