35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import type {
|
|
RuntimeCapabilityId,
|
|
RuntimeCapabilityStatus,
|
|
} from "../../src/contracts/runtime-capabilities.ts";
|
|
import type { RuntimeCapabilitiesPort } from "../../src/application/ports/runtime-capabilities-port.ts";
|
|
|
|
const CAPABILITY_IDS = Object.freeze([
|
|
"REALTIME",
|
|
"WEB_WORKER",
|
|
"SERVICE_WORKER",
|
|
"OFFLINE_COMMANDS",
|
|
] as const);
|
|
|
|
/**
|
|
* A capability port whose snapshot is fixed by the test rather than by the
|
|
* repository's installed selection, so a suite asserting presentation behaviour
|
|
* does not change meaning when a capability is later installed.
|
|
*/
|
|
export function createRuntimeCapabilitiesStub(
|
|
overrides: Readonly<Partial<Record<RuntimeCapabilityId, Partial<RuntimeCapabilityStatus>>>> = {},
|
|
): RuntimeCapabilitiesPort {
|
|
const snapshot = Object.freeze(
|
|
CAPABILITY_IDS.map((capabilityId) =>
|
|
Object.freeze({
|
|
capabilityId,
|
|
selected: 0,
|
|
active: 0,
|
|
override: "DEFAULT" as const,
|
|
...overrides[capabilityId],
|
|
}),
|
|
),
|
|
);
|
|
return Object.freeze({ getSnapshot: () => snapshot });
|
|
}
|