Files
dbx/apps/desktop/src/lib/__tests__/xuguCompileSql.spec.ts
T
352403d79e feat(xugu): add programmable object compile actions
* feat(xugu): add programmable object compile actions

* chore(i18n): autofill new translations

---------

Co-authored-by: mapan <pan.anarkh1994@gmail.com>
Co-authored-by: dbx-i18n-bot <github-actions[bot]@users.noreply.github.com>
2026-08-07 03:30:52 +08:00

34 lines
1.4 KiB
TypeScript
Vendored

import { describe, expect, it } from "vitest";
import { buildXuguCompileSql, xuguCompileKeyword } from "@/lib/database/xuguCompileSql";
describe("xuguCompileSql", () => {
it.each([
["procedure", "PROCEDURE"],
["function", "FUNCTION"],
["trigger", "TRIGGER"],
["package", "PACKAGE"],
["package-body", "PACKAGE"],
["type", "TYPE"],
["type-body", "TYPE"],
])("maps %s to %s", (objectType, keyword) => {
expect(xuguCompileKeyword(objectType)).toBe(keyword);
});
it("quotes schema and object names while preserving mixed case", () => {
expect(buildXuguCompileSql({ objectType: "procedure", schema: "AppSchema", name: "spCreateOrder" })).toBe('ALTER PROCEDURE "AppSchema"."spCreateOrder" RECOMPILE;');
});
it("accepts object-browser uppercase kinds", () => {
expect(buildXuguCompileSql({ objectType: "FUNCTION", name: "f_get_count" })).toBe('ALTER FUNCTION "f_get_count" RECOMPILE;');
});
it("escapes embedded double quotes", () => {
expect(buildXuguCompileSql({ objectType: "trigger", schema: 'A"Schema', name: 'T"1' })).toBe('ALTER TRIGGER "A""Schema"."T""1" RECOMPILE;');
});
it("returns null for unsupported object kinds or blank names", () => {
expect(buildXuguCompileSql({ objectType: "sequence", schema: "SYSDBA", name: "SEQ_1" })).toBeNull();
expect(buildXuguCompileSql({ objectType: "procedure", schema: "SYSDBA", name: " " })).toBeNull();
});
});