-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdist.test.ts
More file actions
38 lines (33 loc) · 1.1 KB
/
dist.test.ts
File metadata and controls
38 lines (33 loc) · 1.1 KB
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
30
31
32
33
34
35
36
37
38
import { describe, it, expect } from "bun:test";
import { Database } from "bun:sqlite";
import { pathToSQLite } from "./dist";
Database.setCustomSQLite(pathToSQLite);
describe("@effect-native/libsqlite", () => {
describe("pathToSQLite", () => {
it("exists", async () => {
expect(await Bun.file(pathToSQLite).exists()).toBeTrue();
});
});
describe("Database", () => {
it("can open a database", () => {
const db = new Database(":memory:");
expect(db).toBeInstanceOf(Database);
expect(db.filename).toMatchInlineSnapshot(`":memory:"`);
expect(
db.query<{ value: number }, []>("SELECT 1 as value").get(),
).toEqual({
value: 1,
});
});
it("is a recent version", () => {
const db = new Database(":memory:");
const { version } = db
.query<{ version: string }, []>("SELECT sqlite_version() as version")
.get() ?? { version: "0.0.0" };
const [_major, minor, _patch] = version
.split(".")
.map((it) => Number.parseInt(it, 10));
expect(minor).toBeGreaterThanOrEqual(50);
});
});
});