summaryrefslogtreecommitdiff
path: root/cli/tests/unit/network_interfaces_test.ts
blob: 120f5876394f7538064f086c572f3c28fb3c3e2d (plain)
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
import { assert } from "./test_util.ts";

Deno.test(
  { name: "Deno.networkInterfaces", permissions: { env: true } },
  () => {
    const networkInterfaces = Deno.networkInterfaces();
    assert(Array.isArray(networkInterfaces));
    assert(networkInterfaces.length > 0);
    for (
      const { name, family, address, netmask, scopeid, cidr, mac }
        of networkInterfaces
    ) {
      assert(typeof name === "string");
      assert(family === "IPv4" || family === "IPv6");
      assert(typeof address === "string");
      assert(typeof netmask === "string");
      assert(
        (family === "IPv6" && typeof scopeid === "number") ||
          (family === "IPv4" && scopeid === null),
      );
      assert(typeof cidr === "string");
      assert(typeof mac === "string");
    }
  },
);