aboutsummaryrefslogtreecommitdiff
path: root/integration/bunjs-only-snippets/buffer.test.js
blob: f8cd3aa5bc5402f60ad9c6d220180ffe1dd3b4d2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
import { describe, it, expect } from "bun:test";

it("buffer", () => {
  var buf = new Buffer(1024);
  expect(buf.write("hello world ")).toBe(12);
  expect(buf.toString("utf8", 0, "hello world ".length)).toBe("hello world ");
  expect(buf.toString("base64url", 0, "hello world ".length)).toBe(
    btoa("hello world ")
  );
  expect(buf instanceof Uint8Array).toBe(true);
  expect(buf instanceof Buffer).toBe(true);
});