|
| 1 | +import { unitTest } from "../test.ts"; |
| 2 | +import { assert } from "testing/asserts"; |
| 3 | +import { |
| 4 | + isHtmlOutput, |
| 5 | + isJatsOutput, |
| 6 | + isPdfOutput, |
| 7 | + isRevealjsOutput, |
| 8 | + isTypstOutput, |
| 9 | +} from "../../src/config/format.ts"; |
| 10 | + |
| 11 | +unitTest( |
| 12 | + "isPdfOutput - direct formats", |
| 13 | + // deno-lint-ignore require-await |
| 14 | + async () => { |
| 15 | + assert(isPdfOutput("pdf")); |
| 16 | + assert(isPdfOutput("beamer")); |
| 17 | + assert(!isPdfOutput("html")); |
| 18 | + assert(!isPdfOutput("typst")); |
| 19 | + assert(!isPdfOutput("docx")); |
| 20 | + }, |
| 21 | +); |
| 22 | + |
| 23 | +unitTest( |
| 24 | + "isPdfOutput - extension formats", |
| 25 | + // deno-lint-ignore require-await |
| 26 | + async () => { |
| 27 | + assert(isPdfOutput("acm-pdf")); |
| 28 | + assert(isPdfOutput("dummy-extension-pdf")); |
| 29 | + assert(isPdfOutput("acm-2023-pdf")); |
| 30 | + assert(isPdfOutput("journal-beamer")); |
| 31 | + assert(!isPdfOutput("acm-html")); |
| 32 | + assert(!isPdfOutput("my-ext-typst")); |
| 33 | + }, |
| 34 | +); |
| 35 | + |
| 36 | +unitTest( |
| 37 | + "isPdfOutput - modifiers and edge cases", |
| 38 | + // deno-lint-ignore require-await |
| 39 | + async () => { |
| 40 | + assert(!isPdfOutput("default")); |
| 41 | + assert(!isPdfOutput("")); |
| 42 | + assert(isPdfOutput("pdf+draft")); |
| 43 | + assert(isPdfOutput("acm-pdf+draft")); |
| 44 | + }, |
| 45 | +); |
| 46 | + |
| 47 | +unitTest( |
| 48 | + "isHtmlOutput - extension formats", |
| 49 | + // deno-lint-ignore require-await |
| 50 | + async () => { |
| 51 | + assert(isHtmlOutput("html")); |
| 52 | + assert(isHtmlOutput("acm-html")); |
| 53 | + assert(isHtmlOutput("nature-html")); |
| 54 | + assert(!isHtmlOutput("acm-pdf")); |
| 55 | + }, |
| 56 | +); |
| 57 | + |
| 58 | +unitTest( |
| 59 | + "isTypstOutput - extension formats", |
| 60 | + // deno-lint-ignore require-await |
| 61 | + async () => { |
| 62 | + assert(isTypstOutput("typst")); |
| 63 | + assert(isTypstOutput("orange-book-typst")); |
| 64 | + assert(!isTypstOutput("acm-pdf")); |
| 65 | + }, |
| 66 | +); |
| 67 | + |
| 68 | +unitTest( |
| 69 | + "isRevealjsOutput - extension formats", |
| 70 | + // deno-lint-ignore require-await |
| 71 | + async () => { |
| 72 | + assert(isRevealjsOutput("revealjs")); |
| 73 | + assert(isRevealjsOutput("clean-revealjs")); |
| 74 | + assert(isRevealjsOutput("my-theme-revealjs")); |
| 75 | + assert(!isRevealjsOutput("html")); |
| 76 | + assert(!isRevealjsOutput("acm-pdf")); |
| 77 | + }, |
| 78 | +); |
| 79 | + |
| 80 | +unitTest( |
| 81 | + "isJatsOutput - extension formats", |
| 82 | + // deno-lint-ignore require-await |
| 83 | + async () => { |
| 84 | + assert(isJatsOutput("jats")); |
| 85 | + assert(isJatsOutput("jats_archiving")); |
| 86 | + assert(isJatsOutput("plos-jats")); |
| 87 | + assert(isJatsOutput("my-journal-jats_archiving")); |
| 88 | + assert(!isJatsOutput("html")); |
| 89 | + assert(!isJatsOutput("acm-pdf")); |
| 90 | + }, |
| 91 | +); |
| 92 | + |
| 93 | +unitTest( |
| 94 | + "format detection - malformed inputs", |
| 95 | + // deno-lint-ignore require-await |
| 96 | + async () => { |
| 97 | + assert(!isPdfOutput("---")); |
| 98 | + assert(!isPdfOutput("123")); |
| 99 | + assert(isHtmlOutput("")); // empty defaults to "html" internally |
| 100 | + assert(!isRevealjsOutput("")); |
| 101 | + assert(!isJatsOutput("")); |
| 102 | + }, |
| 103 | +); |
0 commit comments