fix(i18n): the video menu's download row says "Download…", and counted copy is pluralized
- The row opens the download dialog, so it is labelled so; the download's state ("Downloaded",
"In queue") is its hint, not its label.
- The share dialog's expiry ("1 days") and a link's view count ("1 views") go through i18next's
plural forms (`count`).
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
// @vitest-environment jsdom
|
||||
//
|
||||
// E28 review J4: the video menu's download row was labelled with the download's STATE ("Downloaded",
|
||||
// "In queue") — a row that reads as a status yet opens the download dialog. It is "Download…" now,
|
||||
// the state riding along as the row's hint.
|
||||
import type { ReactNode } from "react";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { cleanup, renderHook, waitFor } from "@testing-library/react";
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
|
||||
vi.mock("react-i18next", async (importOriginal) => ({
|
||||
...(await importOriginal<typeof import("react-i18next")>()),
|
||||
useTranslation: () => ({ t: (k: string) => k }),
|
||||
}));
|
||||
vi.mock("./navigationContext", () => ({ useNavigationActions: () => ({ openChannel: vi.fn() }) }));
|
||||
vi.mock("./comfortPin", () => ({
|
||||
pinVideo: vi.fn(),
|
||||
useComfortPin: () => ({ item: () => [] }),
|
||||
}));
|
||||
|
||||
import { api, type Video } from "../lib/api";
|
||||
import { useVideoActions } from "./useVideoActions";
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
const video = { id: "v1", title: "A video", status: "new", position_seconds: 0 } as Video;
|
||||
|
||||
function downloadRow(state: string | undefined) {
|
||||
vi.spyOn(api, "downloadIndex").mockResolvedValue(
|
||||
(state ? { v1: state } : {}) as Awaited<ReturnType<typeof api.downloadIndex>>,
|
||||
);
|
||||
const qc = new QueryClient({ defaultOptions: { queries: { retry: false } } });
|
||||
const wrapper = ({ children }: { children: ReactNode }) => (
|
||||
<QueryClientProvider client={qc}>{children}</QueryClientProvider>
|
||||
);
|
||||
const { result } = renderHook(
|
||||
() => useVideoActions({ onState: vi.fn(), onToggleSave: vi.fn() }, true),
|
||||
{ wrapper },
|
||||
);
|
||||
return () => result.current.items(video, null).find((i) => i.id === "download")!;
|
||||
}
|
||||
|
||||
describe("the video menu's download row", () => {
|
||||
it("says what it does, whatever the state, and carries the state as its hint", async () => {
|
||||
const done = downloadRow("done");
|
||||
await waitFor(() => expect(done().title).toBe("downloads.button.downloaded"));
|
||||
expect(done().label).toBe("downloads.menu.download");
|
||||
cleanup();
|
||||
const none = downloadRow(undefined);
|
||||
await waitFor(() => expect(none().label).toBe("downloads.menu.download"));
|
||||
expect(none().title).toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user