test(media): type the media router test client
This commit is contained in:
parent
e601b26292
commit
ffcc47710d
@ -59,13 +59,11 @@ const kit = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
type Client = ReturnType<typeof createRouterClient<ReturnType<typeof createMediaRouter>>>;
|
function client(router: ReturnType<typeof createMediaRouter>, actor: Actor | null) {
|
||||||
|
|
||||||
function client(router: ReturnType<typeof createMediaRouter>, actor: Actor | null): Client {
|
|
||||||
return createRouterClient(router, { context: { actor } });
|
return createRouterClient(router, { context: { actor } });
|
||||||
}
|
}
|
||||||
|
|
||||||
function procedure(target: Client, rpcPath: string) {
|
function procedure(target: unknown, rpcPath: string) {
|
||||||
let node: unknown = target;
|
let node: unknown = target;
|
||||||
for (const key of rpcPath.split("/")) node = (node as Record<string, unknown>)[key];
|
for (const key of rpcPath.split("/")) node = (node as Record<string, unknown>)[key];
|
||||||
return node as (input: unknown) => Promise<unknown>;
|
return node as (input: unknown) => Promise<unknown>;
|
||||||
@ -104,7 +102,11 @@ describe("media router without a configured sidecar", () => {
|
|||||||
const capabilities = await client(router, member).capabilities({});
|
const capabilities = await client(router, member).capabilities({});
|
||||||
expect(capabilities).toEqual(unconfiguredCapabilities());
|
expect(capabilities).toEqual(unconfiguredCapabilities());
|
||||||
expect(capabilities.configured).toBe(false);
|
expect(capabilities.configured).toBe(false);
|
||||||
expect(Object.values(capabilities.operations).every((op) => !op.available)).toBe(true);
|
expect(
|
||||||
|
Object.values(capabilities.operations).every(
|
||||||
|
(op) => !(op as { available: boolean }).available,
|
||||||
|
),
|
||||||
|
).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("refuses every other procedure", async () => {
|
it("refuses every other procedure", async () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user