summaryrefslogtreecommitdiff
path: root/tests/unit/network_interfaces_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/network_interfaces_test.ts')
-rw-r--r--tests/unit/network_interfaces_test.ts30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/unit/network_interfaces_test.ts b/tests/unit/network_interfaces_test.ts
new file mode 100644
index 000000000..160efbfe6
--- /dev/null
+++ b/tests/unit/network_interfaces_test.ts
@@ -0,0 +1,30 @@
+// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
+
+import { assert } from "./test_util.ts";
+
+Deno.test(
+ {
+ name: "Deno.networkInterfaces",
+ permissions: { sys: ["networkInterfaces"] },
+ },
+ () => {
+ 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");
+ }
+ },
+);