aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/zlib.test.js
blob: 60f3fe23ad8b579413d78d9c9e6240929c133029 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { describe, it, expect } from "bun:test";
import { gzipSync, deflateSync, inflateSync, gunzipSync } from "bun";

describe("zlib", () => {
  it("should be able to deflate and inflate", () => {
    const data = new TextEncoder().encode("Hello World!".repeat(1));
    const compressed = deflateSync(data);
    const decompressed = inflateSync(compressed);
    expect(decompressed.join("")).toBe(data.join(""));
  });

  it("should be able to gzip and gunzip", () => {
    const data = new TextEncoder().encode("Hello World!".repeat(1));
    const compressed = gzipSync(data);
    const decompressed = gunzipSync(compressed);
    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);
      });
    });
  });
});
sg191/astro/log/examples/starter?h=fix-s-island-fallback&id=efd6548d498aa6dc23cbb010c708139d4eac077d&showmsg=1&follow=1'>starter/.stackblitzrc (unfollow)
AgeCommit message (Collapse)AuthorFilesLines
2022-06-27Refactor: remove Deno shim to esbuild "banner" (#3734)Gravatar Ben Holmes 7-15/+22
* refactor: remove Deno shim to esbuild "banner" * refactor: move shim to const * refactor: add shim to netlify edge * chore: changeset
2022-06-27[ci] formatGravatar FredKSchott 9-23/+25
2022-06-27update telemetry to support more anonymized project id (#3713)Gravatar Fred K. Schott 20-351/+311
* update telemetry to support more anonymized project id * Create strange-laws-kick.md * respond to nate feedback
2022-06-27SImplify "astro add" by removing confusing multi-select (#3715)Gravatar Fred K. Schott 13-258/+157
* wip * update create-astro for new astro add * update copy * update git prompt * Update packages/astro/src/core/logger/node.ts Co-authored-by: Chris Swithinbank <swithinbank@gmail.com> * Update packages/create-astro/test/install-step.test.js Co-authored-by: Chris Swithinbank <swithinbank@gmail.com> * update git prompt * update test Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>