diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2024-02-01 08:51:10 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-01 08:51:10 +0530 |
commit | 02c65fad45898b79ef9614319061d19d24cfb9ce (patch) | |
tree | 4062aa5cfe9ed5e4a071ccb345089f7146248189 /cli/tests/unit_node/util_test.ts | |
parent | 4b7c6049ef9d40394eb823859c82cbf8d293430d (diff) |
fix(node): `util.callbackify` (#22200)
Fixes https://github.com/denoland/deno/issues/22180
Matches the Node.js implementation more closely. Removed types, they do
not help just make it harder to debug with stack traces.
Diffstat (limited to 'cli/tests/unit_node/util_test.ts')
-rw-r--r-- | cli/tests/unit_node/util_test.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/cli/tests/unit_node/util_test.ts b/cli/tests/unit_node/util_test.ts index 2e2bb0021..a88128ee9 100644 --- a/cli/tests/unit_node/util_test.ts +++ b/cli/tests/unit_node/util_test.ts @@ -292,3 +292,26 @@ Deno.test({ fn(); }, }); + +Deno.test({ + name: "[util] callbackify() works", + fn() { + const fn = util.callbackify(() => Promise.resolve("foo")); + fn((err, value) => { + assert(err === null); + assert(value === "foo"); + }); + }, +}); + +Deno.test({ + name: "[util] callbackify(undefined) throws", + fn() { + assertThrows( + // @ts-expect-error: testing runtime error + () => util.callbackify(undefined), + TypeError, + 'The "original" argument must be of type function', + ); + }, +}); |