summaryrefslogtreecommitdiff
path: root/std/node/util_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'std/node/util_test.ts')
-rw-r--r--std/node/util_test.ts40
1 files changed, 39 insertions, 1 deletions
diff --git a/std/node/util_test.ts b/std/node/util_test.ts
index 9b55d0178..9db463b99 100644
--- a/std/node/util_test.ts
+++ b/std/node/util_test.ts
@@ -1,5 +1,11 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-import { assert, assertEquals } from "../testing/asserts.ts";
+
+import {
+ assert,
+ assertEquals,
+ assertStrictEquals,
+ assertThrows,
+} from "../testing/asserts.ts";
import { stripColor } from "../fmt/colors.ts";
import * as util from "./util.ts";
@@ -182,3 +188,35 @@ Deno.test({
assert(util.types.isDate(new Date()));
},
});
+
+Deno.test({
+ name: "[util] getSystemErrorName()",
+ fn() {
+ type FnTestInvalidArg = (code?: unknown) => void;
+
+ assertThrows(
+ () => (util.getSystemErrorName as FnTestInvalidArg)(),
+ TypeError,
+ );
+ assertThrows(
+ () => (util.getSystemErrorName as FnTestInvalidArg)(1),
+ RangeError,
+ );
+
+ assertStrictEquals(util.getSystemErrorName(-424242), undefined);
+
+ switch (Deno.build.os) {
+ case "windows":
+ assertStrictEquals(util.getSystemErrorName(-4091), "EADDRINUSE");
+ break;
+
+ case "darwin":
+ assertStrictEquals(util.getSystemErrorName(-48), "EADDRINUSE");
+ break;
+
+ case "linux":
+ assertStrictEquals(util.getSystemErrorName(-98), "EADDRINUSE");
+ break;
+ }
+ },
+});