import { describe, expect, it } from "vitest"; import { sqlStatements } from "../src/sql-statements.js"; describe("sqlStatements", () => { it("splits a .sql file into named statements at each `-- name:` line, dropping the trailing ;", () => { const text = "-- first:\nselect 1;\n\n-- second:\nselect *\nfrom t\nwhere a = ?;\n"; expect(sqlStatements(text)).toEqual({ first: "select 1", second: "select *\nfrom t\nwhere a = ?" }); }); it("keeps a multi-statement entry whole (inner semicolons stay)", () => { expect(sqlStatements("-- both:\nupdate a set x = 1;\nupdate b set y = 2;\n")).toEqual({ both: "update a set x = 1;\nupdate b set y = 2", }); }); });