summaryrefslogtreecommitdiff
path: root/tests/unit_node/crypto/crypto_misc_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit_node/crypto/crypto_misc_test.ts')
-rw-r--r--tests/unit_node/crypto/crypto_misc_test.ts18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/unit_node/crypto/crypto_misc_test.ts b/tests/unit_node/crypto/crypto_misc_test.ts
new file mode 100644
index 000000000..8132f2e99
--- /dev/null
+++ b/tests/unit_node/crypto/crypto_misc_test.ts
@@ -0,0 +1,18 @@
+// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
+import { randomFillSync, randomUUID } from "node:crypto";
+import { assert, assertEquals } from "../../unit/test_util.ts";
+
+Deno.test("[node/crypto.getRandomUUID] works the same way as Web Crypto API", () => {
+ assertEquals(randomUUID().length, crypto.randomUUID().length);
+ assertEquals(typeof randomUUID(), typeof crypto.randomUUID());
+});
+
+Deno.test("[node/crypto.randomFillSync] supported arguments", () => {
+ const buf = new Uint8Array(10);
+
+ assert(randomFillSync(buf));
+ assert(randomFillSync(buf, 0));
+ // @ts-ignore: arraybuffer arguments are valid.
+ assert(randomFillSync(buf.buffer));
+ assert(randomFillSync(new DataView(buf.buffer)));
+});