diff options
author | 2023-01-22 19:54:42 -0800 | |
---|---|---|
committer | 2023-01-22 19:54:42 -0800 | |
commit | 2cce810190001acf9d55e53770cb02a51682258e (patch) | |
tree | d3ed11170923731b9809841e83de1450635c0c96 /test/bun.js/zlib.test.js | |
parent | eaea08ea454929c9e84e5e0b9294ea3cff4e5a7e (diff) | |
download | bun-2cce810190001acf9d55e53770cb02a51682258e.tar.gz bun-2cce810190001acf9d55e53770cb02a51682258e.tar.zst bun-2cce810190001acf9d55e53770cb02a51682258e.zip |
Add a test for zlib (thanks @jiaz)
Diffstat (limited to 'test/bun.js/zlib.test.js')
-rw-r--r-- | test/bun.js/zlib.test.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/bun.js/zlib.test.js b/test/bun.js/zlib.test.js index aecb095cc..60f3fe23a 100644 --- a/test/bun.js/zlib.test.js +++ b/test/bun.js/zlib.test.js @@ -16,3 +16,24 @@ describe("zlib", () => { expect(decompressed.join("")).toBe(data.join("")); }); }); + +import * as zlib from "node:zlib"; +import * as fs from "node:fs"; +import * as buffer from "node:buffer"; + +describe("zlib.gunzip", () => { + it("should be able to unzip a Buffer and return an unzipped Buffer", async () => { + const content = fs.readFileSync(import.meta.dir + "/fixture.html.gz"); + return new Promise((resolve, reject) => { + zlib.gunzip(content, (error, data) => { + if (error) { + reject(error); + return; + } + expect(data !== null).toBe(true); + expect(buffer.Buffer.isBuffer(data)).toBe(true); + resolve(true); + }); + }); + }); +}); |