File size: 918 Bytes
96e86e5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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,
    });
  });
});