aboutsummaryrefslogtreecommitdiff
path: root/test/js/third_party/mongodb/mongodb.test.ts
blob: da0a089cfb2241395f5a023205960d66fe78f33a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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();
    }
  });
});