import { describe, expect, it } from "vitest"; import { bibtex, citationApa, citationChicago, citationKey, ris, type CitablePaper } from "@/lib/papers/citation"; const p: CitablePaper = { identifier: "WP38", slug: "wp38", title: "The Economic Geography of Digital Retail Supply", subtitle: "Evidence from Quebec", year: 2026, authors: [{ givenName: "Simon-Pierre", familyName: "Boucher" }], seriesName: "UQO Working Papers", institution: "Université du Québec en Outaouais", url: "https://wp.spboucher.ai/papers/wp38", versionLabel: "v1.0", keywords: ["economic geography", "Quebec"], abstract: ["Para one.", "Para two."], releasedOn: "2026-11-01", releasedPrecision: "month" }; describe("citations", () => { it("APA", () => { expect(citationApa(p)).toBe("Boucher, S.-P. (2026). The Economic Geography of Digital Retail Supply: Evidence from Quebec (UQO Working Papers WP38, v1.0). Université du Québec en Outaouais. https://wp.spboucher.ai/papers/wp38"); }); it("APA with three authors", () => { const q = { ...p, authors: [{ givenName: "Manel", familyName: "Kammoun" }, { givenName: "Djerrycharli", familyName: "Tandjambianda" }, { givenName: "Simon-Pierre", familyName: "Boucher" }] }; expect(citationApa(q)).toContain("Kammoun, M., Tandjambianda, D., & Boucher, S.-P. (2026)"); }); it("Chicago", () => { expect(citationChicago(p)).toContain("Boucher, Simon-Pierre. 2026. “The Economic Geography"); }); it("BibTeX has month, number, type and escaped fields", () => { const b = bibtex(p); expect(b).toContain("@techreport{boucher2026wp38,"); expect(b).toContain("month = nov,"); expect(b).toContain("number = {WP38},"); expect(b).toContain("type = {UQO Working Papers},"); expect(b).toContain("keywords = {economic geography, Quebec},"); expect(b.endsWith("}")).toBe(true); }); it("BibTeX omits month when precision is year", () => { expect(bibtex({ ...p, releasedPrecision: "year" })).not.toContain("month ="); }); it("RIS", () => { const r = ris(p); expect(r.startsWith("TY - RPRT")).toBe(true); expect(r).toContain("AU - Boucher, Simon-Pierre"); expect(r).toContain("DA - 2026/11//"); expect(r).toContain("M1 - WP38"); expect(r.trim().endsWith("ER -")).toBe(true); }); it("DOI wins over URL", () => { expect(citationApa({ ...p, doi: "10.1000/xyz" })).toContain("https://doi.org/10.1000/xyz"); }); it("citation key strips accents", () => { expect(citationKey({ ...p, authors: [{ givenName: "É", familyName: "Côté-Léger" }] })).toBe("coteleger2026wp38"); }); });