diff options
author | 2023-01-16 12:49:34 -0800 | |
---|---|---|
committer | 2023-01-16 12:49:57 -0800 | |
commit | 4648131c416ad708c339789dd1979d4d8e738dd8 (patch) | |
tree | 3eacabac543e8c0e7eb744798c798155c6046812 /test/bun.js/buffer.test.js | |
parent | b0702ce7b156f9dbeb3f4f65fe94b12044e28334 (diff) | |
download | bun-4648131c416ad708c339789dd1979d4d8e738dd8.tar.gz bun-4648131c416ad708c339789dd1979d4d8e738dd8.tar.zst bun-4648131c416ad708c339789dd1979d4d8e738dd8.zip |
Add missing `buffer` module exports
Diffstat (limited to 'test/bun.js/buffer.test.js')
-rw-r--r-- | test/bun.js/buffer.test.js | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/test/bun.js/buffer.test.js b/test/bun.js/buffer.test.js index d263a80eb..64c6cc41f 100644 --- a/test/bun.js/buffer.test.js +++ b/test/bun.js/buffer.test.js @@ -1,6 +1,8 @@ import { describe, it, expect, beforeEach, afterEach } from "bun:test"; import { gc } from "./gc"; +const BufferModule = await import("buffer"); + beforeEach(() => gc()); afterEach(() => gc()); @@ -560,7 +562,7 @@ it("Buffer.swap16", () => { const examples = [ ["", ""], ["a1", "1a"], - ["a1b2", "1a2b"] + ["a1b2", "1a2b"], ]; for (let i = 0; i < examples.length; i++) { @@ -586,7 +588,7 @@ it("Buffer.swap32", () => { const examples = [ ["", ""], ["a1b2", "2b1a"], - ["a1b2c3d4", "2b1a4d3c"] + ["a1b2c3d4", "2b1a4d3c"], ]; for (let i = 0; i < examples.length; i++) { @@ -698,3 +700,21 @@ it("Buffer can be mocked", () => { buf.writeBigUInt64LE(0); }).not.toThrow(); }); + +it("constants", () => { + expect(BufferModule.constants.MAX_LENGTH).toBe(4294967296); + expect(BufferModule.constants.MAX_STRING_LENGTH).toBe(536870888); + expect(BufferModule.default.constants.MAX_LENGTH).toBe(4294967296); + expect(BufferModule.default.constants.MAX_STRING_LENGTH).toBe(536870888); +}); + +it("File", () => { + expect(BufferModule.File).toBe(Blob); +}); + +it("transcode", () => { + expect(typeof BufferModule.transcode).toBe("undefined"); + + // This is a masqueradesAsUndefined function + expect(() => BufferModule.transcode()).toThrow("Not implemented"); +}); |