Files
jellytau/src/lib/components/player/mediaReady.test.ts
T
dtourolle ad48d89dfe chore(format): run prettier over src/ and scripts/
Formatting was configured but never enforced: `bun run format:check`
reported 199 unformatted files and ran in no workflow and in no git hook,
so .prettierrc (printWidth 100, trailing commas) described an intention
rather than the tree.

This is the one-time sweep that makes the check gateable. Whitespace and
token-reflow only -- no behavioural change: `bun run check` reports 0
errors and all 1053 frontend tests pass before and after.

Kept out of every other commit on purpose. A 199-file diff mixed with
real changes is unreviewable, and the next commit turns format:check
into a hard CI gate so this cannot silently accumulate again.
2026-08-21 17:41:44 +02:00

42 lines
1.5 KiB
TypeScript

/**
* Native-path reveal rule (DR-182).
*
* TRACES: UR-003, UR-004 | DR-182 | UT-184
*/
import { describe, it, expect } from "vitest";
import { nativeSignalRevealsVideo } from "./mediaReady";
describe("nativeSignalRevealsVideo", () => {
it("reveals on the backend's playing state", () => {
expect(nativeSignalRevealsVideo({ kind: "state", state: "playing" })).toBe(true);
});
it.each(["buffering", "paused", "stopped", "ended", "error", "idle", ""])(
"leaves the poster up on state %s",
(state) => {
expect(nativeSignalRevealsVideo({ kind: "state", state })).toBe(false);
},
);
it("reveals on a position tick that carries a duration", () => {
expect(nativeSignalRevealsVideo({ kind: "position", position: 0, duration: 1440 })).toBe(true);
});
it("reveals on a position tick that has advanced, even with no duration", () => {
// Live streams report no duration; an advancing position is still proof
// that the surface has content.
expect(nativeSignalRevealsVideo({ kind: "position", position: 3.2, duration: 0 })).toBe(true);
});
it("leaves the poster up on an empty position tick", () => {
// A tick before anything is loaded proves nothing, and revealing here would
// show a transparent hole through the app.
expect(nativeSignalRevealsVideo({ kind: "position", position: 0, duration: 0 })).toBe(false);
});
it("does not treat a negative position as progress", () => {
expect(nativeSignalRevealsVideo({ kind: "position", position: -1, duration: 0 })).toBe(false);
});
});