feat: format sql (#19)

Co-authored-by: SuLe <sule@SuLedeMacBook-Air.local>
This commit is contained in:
SuLea-IT
2026-04-30 15:56:16 +08:00
committed by GitHub
co-authored by SuLe
parent ac76aadbed
commit 5ee4f9300f
8 changed files with 196 additions and 1 deletions
+16
View File
@@ -0,0 +1,16 @@
import { strict as assert } from "node:assert";
import test from "node:test";
import { formatSqlText } from "../src/lib/sqlFormatter.js";
test("formats SQL with uppercase keywords and readable line breaks", async () => {
const formatted = await formatSqlText("select id, name from users where active = 1 order by name", "postgres");
assert.match(formatted, /^SELECT\b/);
assert.match(formatted, /\nFROM\b/);
assert.match(formatted, /\nWHERE\b/);
assert.match(formatted, /\nORDER BY\b/);
});
test("leaves blank SQL unchanged", async () => {
assert.equal(await formatSqlText(" \n\t", "mysql"), " \n\t");
});