02b16e311b
The generated script's setup comment hardcoded school.second-brain.ru even though baseUrl is already interpolated elsewhere in the template, so the comment would lie on any other host. Also add a regression test that the generated script parses as valid JavaScript, to catch escaping mistakes in the template literal.
18 lines
774 B
TypeScript
18 lines
774 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { buildZoteroScript } from "@/lib/clean-pdf/zotero-script";
|
|
|
|
describe("buildZoteroScript", () => {
|
|
it("подставляет ключ и адрес школы", () => {
|
|
const s = buildZoteroScript({ apiKey: "sbpdf_test123", baseUrl: "https://school.second-brain.ru" });
|
|
expect(s).toContain("'sbpdf_test123'");
|
|
expect(s).toContain("'https://school.second-brain.ru'");
|
|
expect(s).toContain("/api/pdf?url=");
|
|
expect(s).not.toContain("YOUR_KEY");
|
|
});
|
|
|
|
it("генерирует синтаксически валидный JS", () => {
|
|
const s = buildZoteroScript({ apiKey: "sbpdf_test123", baseUrl: "https://school.second-brain.ru" });
|
|
expect(() => new Function(s)).not.toThrow();
|
|
});
|
|
});
|