mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-15 02:20:38 +09:00
29 lines
918 B
TypeScript
29 lines
918 B
TypeScript
|
|
import { describe, expect, it } from "vitest";
|
||
|
|
import { sanitizeWorkspaceRuntimeControlTarget } from "./workspace-runtime-control";
|
||
|
|
|
||
|
|
describe("sanitizeWorkspaceRuntimeControlTarget", () => {
|
||
|
|
it("drops unexpected keys while preserving the selected runtime target", () => {
|
||
|
|
const sanitized = sanitizeWorkspaceRuntimeControlTarget({
|
||
|
|
workspaceCommandId: "web",
|
||
|
|
runtimeServiceId: "service-1",
|
||
|
|
serviceIndex: 2,
|
||
|
|
...( { action: "start" } as Record<string, unknown> ),
|
||
|
|
});
|
||
|
|
|
||
|
|
expect(sanitized).toEqual({
|
||
|
|
workspaceCommandId: "web",
|
||
|
|
runtimeServiceId: "service-1",
|
||
|
|
serviceIndex: 2,
|
||
|
|
});
|
||
|
|
expect("action" in sanitized).toBe(false);
|
||
|
|
});
|
||
|
|
|
||
|
|
it("normalizes an omitted target to nullable fields", () => {
|
||
|
|
expect(sanitizeWorkspaceRuntimeControlTarget()).toEqual({
|
||
|
|
workspaceCommandId: null,
|
||
|
|
runtimeServiceId: null,
|
||
|
|
serviceIndex: null,
|
||
|
|
});
|
||
|
|
});
|
||
|
|
});
|