File size: 1,082 Bytes
fcd8223
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import { describe, expect, it, vi } from "vitest";
import { resolveNodeHostGatewayPlatformIdentity } from "./gateway-platform-identity.js";

describe("resolveNodeHostGatewayPlatformIdentity", () => {
  it.each([
    { runtime: "darwin", platform: "macos", deviceFamily: "Mac", modelIdentifier: "Mac16,1" },
    { runtime: "linux", platform: "linux", deviceFamily: "Linux", modelIdentifier: "Test Board" },
    { runtime: "win32", platform: "windows", deviceFamily: "Windows", modelIdentifier: undefined },
    {
      runtime: "freebsd",
      platform: "freebsd",
      deviceFamily: undefined,
      modelIdentifier: undefined,
    },
  ] as const)(
    "reports $runtime hardware identity",
    ({ runtime, platform, deviceFamily, modelIdentifier }) => {
      const resolveModel = vi.fn(() => modelIdentifier);
      expect(resolveNodeHostGatewayPlatformIdentity(runtime, resolveModel)).toEqual({
        platform,
        ...(deviceFamily ? { deviceFamily, modelIdentifier } : {}),
      });
      expect(resolveModel).toHaveBeenCalledExactlyOnceWith(runtime);
    },
  );
});