summaryrefslogtreecommitdiff
path: root/std/node/buffer_test.ts
diff options
context:
space:
mode:
authorMarcos Casagrande <marcoscvp90@gmail.com>2020-06-28 18:27:02 +0200
committerGitHub <noreply@github.com>2020-06-28 12:27:02 -0400
commit0374eadcf7ecb054dae1b1587843a2006fdf4c2d (patch)
treeef341276515bcfbd8b1991b798cd4004411a58d7 /std/node/buffer_test.ts
parent96b4a5f837fe984a91c03babc398fb55a6210610 (diff)
feat(std/node): Add Buffer.isEncoding (#6521)
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);
+ });
+ },
+});