import { it, expect } from "bun:test"; it("Blob inspect", () => { expect(Bun.inspect(new Blob(["123"]))).toBe(`Blob (3 bytes)`); expect(Bun.inspect(new Blob(["123".repeat(900)]))).toBe(`Blob (3 KB)`); expect(Bun.inspect(Bun.file("/tmp/file.txt"))) .toBe(`FileRef ("/tmp/file.txt") { type: "text/plain;charset=utf-8" }`); expect(Bun.inspect(Bun.file(123))).toBe(`FileRef (fd: 123) { type: "application/octet-stream" }`); expect(Bun.inspect(new Response(""))).toBe(`Response (0 KB) { ok: true, url: "", statusText: "", redirected: false, bodyUsed: false, status: 200, [Blob detached] }`); expect(Bun.inspect(new Response("Hello"))).toBe(`Response (5 bytes) { ok: true, url: "", statusText: "", redirected: false, bodyUsed: false, status: 200, Blob (5 bytes) }`); }); it("utf16 property name", () => { var { Database } = require("bun:sqlite"); const db = Database.open(":memory:"); expect(Bun.inspect(db.prepare("select '😀' as 笑").all())).toBe( '[ { "笑": "😀" } ]' ); }); it("latin1", () => { expect(Bun.inspect("English")).toBe("English"); expect(Bun.inspect("Français")).toBe("Français"); expect(Bun.inspect("Ελληνική")).toBe("Ελληνική"); expect(Bun.inspect("日本語")).toBe("日本語"); expect(Bun.inspect("Emoji😎")).toBe("Emoji😎"); expect(Bun.inspect("Français / Ελληνική")).toBe("Français / Ελληνική"); }); it("Request object", () => { expect(Bun.inspect(new Request({ url: "https://example.com" })).trim()).toBe( ` Request (0 KB) { method: "GET", url: "https://example.com" }`.trim() ); }); // https://github.com/oven-sh/bun/issues/561 it("TypedArray prints", () => { // TODO: add tests for all variants of typed arrays // even if the code is the same for each implementation, we should test it const buffer = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); const input = Bun.inspect(buffer); expect(input).toBe( `Uint8Array(${buffer.length}) [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]` ); for (let i = 1; i < buffer.length + 1; i++) { expect(Bun.inspect(buffer.subarray(i))).toBe( `Uint8Array(${buffer.length - i}) [ ` + [...buffer.subarray(i)].join(", ") + " ]" ); } }); it("jsx with two elements", () => { const input = Bun.inspect(