summaryrefslogtreecommitdiff
path: root/std/node/buffer_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'std/node/buffer_test.ts')
-rw-r--r--std/node/buffer_test.ts47
1 files changed, 47 insertions, 0 deletions
diff --git a/std/node/buffer_test.ts b/std/node/buffer_test.ts
index 105bc284e..4e6dc9afc 100644
--- a/std/node/buffer_test.ts
+++ b/std/node/buffer_test.ts
@@ -471,3 +471,50 @@ Deno.test({
assertEquals(slice.toString(), "deno");
},
});
+
+Deno.test({
+ name: "isEncoding returns true for valid encodings",
+ fn() {
+ [
+ "hex",
+ "HEX",
+ "HeX",
+ "utf8",
+ "utf-8",
+ "ascii",
+ "latin1",
+ "binary",
+ "base64",
+ "BASE64",
+ "BASe64",
+ "ucs2",
+ "ucs-2",
+ "utf16le",
+ "utf-16le",
+ ].forEach((enc) => {
+ assertEquals(Buffer.isEncoding(enc), true);
+ });
+ },
+});
+
+Deno.test({
+ name: "isEncoding returns false for invalid encodings",
+ fn() {
+ [
+ "utf9",
+ "utf-7",
+ "Unicode-FTW",
+ "new gnu gun",
+ false,
+ NaN,
+ {},
+ Infinity,
+ [],
+ 1,
+ 0,
+ -1,
+ ].forEach((enc) => {
+ assertEquals(Buffer.isEncoding(enc), false);
+ });
+ },
+});