From 972a6f29cc0d232982ad9d2cae493c8a5cc7a74a Mon Sep 17 00:00:00 2001 From: Ciro Spaciari Date: Wed, 13 Sep 2023 17:41:47 -0700 Subject: fix(console.log) fix printing long custom format (#5164) * avoid overflow * Update src/bun.js/bindings/exports.zig * add mongodb inspect test * bun db test --------- Co-authored-by: Jarred Sumner --- src/bun.js/bindings/exports.zig | 2 +- test/js/third_party/mongodb/mongodb.test.ts | 29 +++++++++++++++++++++++++++++ test/js/third_party/mongodb/package.json | 6 ++++++ test/package.json | 3 ++- 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 test/js/third_party/mongodb/mongodb.test.ts create mode 100644 test/js/third_party/mongodb/package.json diff --git a/src/bun.js/bindings/exports.zig b/src/bun.js/bindings/exports.zig index 18b7c8bce..66bbe798f 100644 --- a/src/bun.js/bindings/exports.zig +++ b/src/bun.js/bindings/exports.zig @@ -2119,7 +2119,7 @@ pub const ZigConsoleClient = struct { this.globalThis, this.custom_formatted_object.function, this.custom_formatted_object.this, - this.max_depth - this.depth, + this.max_depth -| this.depth, this.max_depth, enable_ansi_colors, ); diff --git a/test/js/third_party/mongodb/mongodb.test.ts b/test/js/third_party/mongodb/mongodb.test.ts new file mode 100644 index 000000000..da0a089cf --- /dev/null +++ b/test/js/third_party/mongodb/mongodb.test.ts @@ -0,0 +1,29 @@ +import { test, expect, describe } from "bun:test"; +import { MongoClient } from "mongodb"; + +const CONNECTION_STRING = process.env.TLS_MONGODB_DATABASE_URL; + +const it = CONNECTION_STRING ? test : test.skip; + +describe("mongodb", () => { + it("should connect and inpect", async () => { + const client = new MongoClient(CONNECTION_STRING as string); + + const clientConnection = await client.connect(); + + try { + const db = client.db("bun"); + + const schema = db.collection("bun"); + + await schema.insertOne({ name: "bunny", version: 1.0 }); + const result = await schema.find(); + await schema.deleteOne({ name: "bunny" }); + const text = Bun.inspect(result); + + expect(text).toBeDefined(); + } finally { + await clientConnection.close(); + } + }); +}); diff --git a/test/js/third_party/mongodb/package.json b/test/js/third_party/mongodb/package.json new file mode 100644 index 000000000..b7cdb0b5c --- /dev/null +++ b/test/js/third_party/mongodb/package.json @@ -0,0 +1,6 @@ +{ + "name": "mongodb", + "dependencies": { + "mongodb": "6.0.0" + } +} diff --git a/test/package.json b/test/package.json index 58e66833f..bab0e7200 100644 --- a/test/package.json +++ b/test/package.json @@ -35,7 +35,8 @@ "undici": "5.20.0", "vitest": "0.32.2", "webpack": "5.88.0", - "webpack-cli": "4.7.2" + "webpack-cli": "4.7.2", + "mongodb": "6.0.0" }, "private": true, "scripts": { -- cgit v1.2.3