diff options
author | Schwarzkopf Balázs <schwarzkopfb@icloud.com> | 2020-09-22 22:07:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-22 16:07:35 -0400 |
commit | f601721851bdd64ee5b40bd3d408df063691b425 (patch) | |
tree | 2b226b6080b152cb967a15af4ca0f6ac35bf014f /std/node/util_test.ts | |
parent | dd1cd4d95237359acd822143265d7d2365bf928c (diff) |
feat(std/node): implement getSystemErrorName() (#7624)
Diffstat (limited to 'std/node/util_test.ts')
-rw-r--r-- | std/node/util_test.ts | 40 |
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; + } + }, +}); |