-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.mjs
More file actions
35 lines (30 loc) · 1.31 KB
/
test.mjs
File metadata and controls
35 lines (30 loc) · 1.31 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
import { test } from "node:test";
import assert from "node:assert";
import { readFile } from "node:fs/promises";
import { fileURLToPath } from "node:url";
import { dirname, join } from "node:path";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
// Mock fetch for Node.js to load local wasm file
globalThis.fetch = async (url) => {
const filePath = join(__dirname, url);
const buffer = await readFile(filePath);
return {
arrayBuffer: async () => buffer.buffer,
};
};
// Now import the modules
const { sqldef } = await import("./sqldef.mjs");
const { schemaExamples } = await import("./schema_examples.mjs");
for (const [dbType, example] of Object.entries(schemaExamples)) {
test(`sqldef returns non-empty string for ${dbType} (enableDrop=false)`, async () => {
const result = await sqldef(dbType, example.desired, example.current, false);
assert.strictEqual(typeof result, "string");
assert.ok(result.length > 0, `Result should be non-empty for ${dbType}`);
});
test(`sqldef returns non-empty string for ${dbType} (enableDrop=true)`, async () => {
const result = await sqldef(dbType, example.desired, example.current, true);
assert.strictEqual(typeof result, "string");
assert.ok(result.length > 0, `Result should be non-empty for ${dbType}`);
});
}