fix(editor): avoid bundling unused Shiki languages
This commit is contained in:
4 files changed
+76
-25
No files matched your search
@@ -8,6 +8,49 @@ describe("escapeHtml", () => {
|
||||
});
|
||||
|
||||
describe("createSafeSqlHighlighter", () => {
|
||||
it("keeps the default GitHub themes", () => {
|
||||
const codeToHtml = vi.fn(() => "<span>SELECT 1</span>");
|
||||
const highlighter = createSafeSqlHighlighter({ codeToHtml }, { appearance: () => "light" });
|
||||
|
||||
expect(highlighter("SELECT 1")).toBe("<span>SELECT 1</span>");
|
||||
expect(highlighter("SELECT 2", "dark")).toBe("<span>SELECT 1</span>");
|
||||
expect(codeToHtml).toHaveBeenNthCalledWith(1, "SELECT 1", {
|
||||
lang: "sql",
|
||||
structure: "inline",
|
||||
theme: "github-light",
|
||||
});
|
||||
expect(codeToHtml).toHaveBeenNthCalledWith(2, "SELECT 2", {
|
||||
lang: "sql",
|
||||
structure: "inline",
|
||||
theme: "github-dark",
|
||||
});
|
||||
});
|
||||
|
||||
it("uses the existing SQL preview themes", () => {
|
||||
const codeToHtml = vi.fn(() => "<span>SELECT 1</span>");
|
||||
const highlighter = createSafeSqlHighlighter(
|
||||
{ codeToHtml },
|
||||
{
|
||||
appearance: () => "light",
|
||||
themePreset: "preview",
|
||||
},
|
||||
);
|
||||
|
||||
highlighter("SELECT 1");
|
||||
highlighter("SELECT 2", "dark");
|
||||
|
||||
expect(codeToHtml).toHaveBeenNthCalledWith(1, "SELECT 1", {
|
||||
lang: "sql",
|
||||
structure: "inline",
|
||||
theme: "min-light",
|
||||
});
|
||||
expect(codeToHtml).toHaveBeenNthCalledWith(2, "SELECT 2", {
|
||||
lang: "sql",
|
||||
structure: "inline",
|
||||
theme: "dark-plus",
|
||||
});
|
||||
});
|
||||
|
||||
it("falls back to escaped SQL when Shiki highlighting fails", () => {
|
||||
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
||||
const highlighter = createSafeSqlHighlighter(
|
||||
|
||||
Reference in new issue
Block a user