Path: blob/main/tests/unit/config/format.test.ts
12925 views
/*1* format.test.ts2*3* Unit tests for format detection functions in src/config/format.ts4*/56import { unitTest } from "../../test.ts";7import { assert } from "testing/asserts";89import {10isTypstOutput,11isLatexOutput,12isPdfOutput,13isHtmlDocOutput,14isBeamerOutput,15isEpubOutput,16isDocxOutput,17isHtmlSlideOutput,18isHtmlDashboardOutput,19} from "../../../src/config/format.ts";202122unitTest("format-detection - isTypstOutput with base format", async () => {23assert(isTypstOutput("typst") === true);24assert(isTypstOutput({ to: "typst" }) === true);25});2627unitTest("format-detection - isTypstOutput with variants (CURRENTLY FAILS)", async () => {28assert(isTypstOutput("typst-citations") === true);29assert(isTypstOutput("typst+custom") === true);30assert(isTypstOutput({ to: "typst-citations" }) === true);31});3233unitTest("format-detection - isTypstOutput negative cases", async () => {34assert(isTypstOutput("pdf") === false);35assert(isTypstOutput("latex") === false);36assert(isTypstOutput({ to: "html" }) === false);37});3839unitTest("format-detection - isLatexOutput with base formats", async () => {40assert(isLatexOutput({ to: "latex" }) === true);41assert(isLatexOutput({ to: "pdf" }) === true);42assert(isLatexOutput({ to: "beamer" }) === true);43});4445unitTest("format-detection - isLatexOutput with variants", async () => {46assert(isLatexOutput({ to: "latex-citations" }) === true);47assert(isLatexOutput({ to: "pdf+smart" }) === true);48assert(isLatexOutput({ to: "beamer-citations" }) === true);49});5051unitTest("format-detection - isLatexOutput negative cases", async () => {52assert(isLatexOutput({ to: "html" }) === false);53assert(isLatexOutput({ to: "typst" }) === false);54});5556unitTest("format-detection - isHtmlDocOutput with base formats", async () => {57assert(isHtmlDocOutput("html") === true);58assert(isHtmlDocOutput("html4") === true);59assert(isHtmlDocOutput("html5") === true);60assert(isHtmlDocOutput({ to: "html" }) === true);61});6263unitTest("format-detection - isHtmlDocOutput with variants", async () => {64assert(isHtmlDocOutput("html-citations") === true);65assert(isHtmlDocOutput("html5+smart") === true);66assert(isHtmlDocOutput({ to: "html+citations" }) === true);67});6869unitTest("format-detection - isHtmlDocOutput negative cases", async () => {70assert(isHtmlDocOutput("revealjs") === false);71assert(isHtmlDocOutput("pdf") === false);72assert(isHtmlDocOutput({ to: "typst" }) === false);73});7475unitTest("format-detection - isPdfOutput with base formats", async () => {76assert(isPdfOutput("pdf") === true);77assert(isPdfOutput("beamer") === true);78assert(isPdfOutput({ to: "pdf" }) === true);79assert(isPdfOutput({ to: "beamer" }) === true);80});8182unitTest("format-detection - isPdfOutput with variants", async () => {83assert(isPdfOutput("pdf-citations") === true);84assert(isPdfOutput("beamer+smart") === true);85assert(isPdfOutput({ to: "pdf+variant" }) === true);86});8788unitTest("format-detection - isPdfOutput negative cases", async () => {89assert(isPdfOutput("html") === false);90assert(isPdfOutput("typst") === false);91assert(isPdfOutput({ to: "latex" }) === false);92});9394unitTest("format-detection - isBeamerOutput with base format", async () => {95assert(isBeamerOutput({ to: "beamer" }) === true);96});9798unitTest("format-detection - isBeamerOutput with variants", async () => {99assert(isBeamerOutput({ to: "beamer-citations" }) === true);100assert(isBeamerOutput({ to: "beamer+smart" }) === true);101});102103unitTest("format-detection - isEpubOutput with base formats", async () => {104assert(isEpubOutput("epub") === true);105assert(isEpubOutput("epub2") === true);106assert(isEpubOutput("epub3") === true);107});108109unitTest("format-detection - isEpubOutput with variants", async () => {110assert(isEpubOutput("epub+citations") === true);111assert(isEpubOutput({ to: "epub3+smart" }) === true);112});113114unitTest("format-detection - isDocxOutput with base format", async () => {115assert(isDocxOutput("docx") === true);116assert(isDocxOutput({ to: "docx" }) === true);117});118119unitTest("format-detection - isDocxOutput with variants", async () => {120assert(isDocxOutput("docx+citations") === true);121assert(isDocxOutput({ to: "docx+smart" }) === true);122});123124unitTest("format-detection - isHtmlSlideOutput with base formats", async () => {125assert(isHtmlSlideOutput("revealjs") === true);126assert(isHtmlSlideOutput("slidy") === true);127assert(isHtmlSlideOutput({ to: "revealjs" }) === true);128});129130unitTest("format-detection - isHtmlSlideOutput with variants", async () => {131assert(isHtmlSlideOutput("revealjs-citations") === true);132assert(isHtmlSlideOutput({ to: "slidy+smart" }) === true);133});134135unitTest("format-detection - isHtmlDashboardOutput with base format", async () => {136assert(isHtmlDashboardOutput("dashboard") === true);137});138139unitTest("format-detection - isHtmlDashboardOutput with custom suffix", async () => {140assert(isHtmlDashboardOutput("my-dashboard") === true);141assert(isHtmlDashboardOutput("custom-dashboard") === true);142});143144145