aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/inspect.test.js
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-07-11 04:34:38 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-07-11 04:34:38 -0700
commitd6d8c0b80dc689de05d8dfe4306e6966f6ffb07e (patch)
treeb78189b9d900c1c73b1f4effab8bc6774cd4c5e2 /test/bun.js/inspect.test.js
parentd9491fe022779de98ccc39a2de6c1196280fac39 (diff)
downloadbun-d6d8c0b80dc689de05d8dfe4306e6966f6ffb07e.tar.gz
bun-d6d8c0b80dc689de05d8dfe4306e6966f6ffb07e.tar.zst
bun-d6d8c0b80dc689de05d8dfe4306e6966f6ffb07e.zip
Fixes https://github.com/oven-sh/bun/issues/561
Diffstat (limited to 'test/bun.js/inspect.test.js')
-rw-r--r--test/bun.js/inspect.test.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/bun.js/inspect.test.js b/test/bun.js/inspect.test.js
index bf5021c33..d58b8a6bc 100644
--- a/test/bun.js/inspect.test.js
+++ b/test/bun.js/inspect.test.js
@@ -1,5 +1,25 @@
import { it, expect } from "bun:test";
+// 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(
<div hello="quoted">