diff options
Diffstat (limited to 'cli/tests/unit_node/zlib_test.ts')
-rw-r--r-- | cli/tests/unit_node/zlib_test.ts | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/cli/tests/unit_node/zlib_test.ts b/cli/tests/unit_node/zlib_test.ts index 1819be268..fa94493c1 100644 --- a/cli/tests/unit_node/zlib_test.ts +++ b/cli/tests/unit_node/zlib_test.ts @@ -9,6 +9,8 @@ import { createBrotliCompress, createBrotliDecompress, createDeflate, + gzipSync, + unzipSync, } from "node:zlib"; import { Buffer } from "node:buffer"; import { createReadStream, createWriteStream } from "node:fs"; @@ -32,6 +34,13 @@ Deno.test("brotli compression async", async () => { assertEquals(decompressed.toString(), "hello world"); }); +Deno.test("gzip compression sync", { sanitizeResources: false }, () => { + const buf = Buffer.from("hello world"); + const compressed = gzipSync(buf); + const decompressed = unzipSync(compressed); + assertEquals(decompressed.toString(), "hello world"); +}); + Deno.test("brotli compression", async () => { const { promise, resolve } = Promise.withResolvers<void>(); const compress = createBrotliCompress(); @@ -125,3 +134,24 @@ Deno.test("should work with a buffer from an encoded string", () => { const decompressed = brotliDecompressSync(compressed); assertEquals(decompressed.toString(), "hello world"); }); + +Deno.test( + "zlib compression with dataview", + { sanitizeResources: false }, + () => { + const buf = Buffer.from("hello world"); + const compressed = gzipSync(new DataView(buf.buffer)); + const decompressed = unzipSync(compressed); + assertEquals(decompressed.toString(), "hello world"); + }, +); + +Deno.test("zlib compression with an encoded string", { + sanitizeResources: false, +}, () => { + const encoder = new TextEncoder(); + const buffer = encoder.encode("hello world"); + const compressed = gzipSync(buffer); + const decompressed = unzipSync(compressed); + assertEquals(decompressed.toString(), "hello world"); +}); |