-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
36 lines (31 loc) · 880 Bytes
/
test.js
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
const Knex = require("knex");
const Client_Libsql = require(".");
const url = process.env.URL ?? "ws://localhost:8080";
let knex;
beforeEach(async () => {
knex = Knex({
client: Client_Libsql,
connection: {
filename: url,
},
useNullAsDefault: true,
});
await knex.schema.dropTableIfExists("t");
await knex.schema.createTable("t", (t) => {
t.integer("id").primary();
t.text("a").notNullable();
t.text("b");
});
});
afterEach(() => {
knex.destroy();
});
test("insert and get rows", async () => {
await knex("t").insert({id: 1, a: "one", b: "ten"});
await knex("t").insert({id: 2, a: "two", b: "twenty"});
const rows = await knex("t").select().orderBy("id");
expect(rows).toEqual([
{id: 1, a: "one", b: "ten"},
{id: 2, a: "two", b: "twenty"},
]);
});