Path: blob/main/tests/smoke/authors/author-name.test.ts
12925 views
/*1* authors-name.test.ts2*3* Copyright (C) 2020-2022 Posit Software, PBC4*5*/67import { ensureFileRegexMatches } from "../../verify.ts";8import { testRender } from "../render/render.ts";910// TODO: Add verification of the name parsing and breaking.11const authorNames = [12"Mine",13"Charles Teague",14"Charles von Teague",15"Alice Jane Malloc",16"Memes, Cat Jane",17"Memes, Cat J",18"Memes, C J",19"Ludwig von Beethoven",20"\n name: Prince",21"\n name:\n literal: Pedro Martinez",22"\n name:\n family: Teague\n given: Charles",23];24const templateContents = `25<html>26<head></head>27<body>28$for(by-author)$29<p>LITERAL</p>30<p class="literal">$by-author.name.literal$</p>3132<p>GIVEN</p>33<p class="given">$by-author.name.given$</p>3435<p>FAMILY</p>36<p class="family">$by-author.name.family$</p>3738<p>DROPPING PART</p>39<p class="dropping-particle">$by-author.name.dropping-particle$<p>4041<p>NON-DROPPING PART</p>42<p class="non-dropping-particle">$by-author.name.non-dropping-particle$<p>43$endfor$44</body>45</html>46`;4748const documentContents = `---49title: Hello World50author: !!author!!51template: !!template!!52---5354## This is a test5556This is the body57`;5859for (const name of authorNames) {60const template = Deno.makeTempFileSync();61Deno.writeTextFileSync(template, templateContents);6263const document = Deno.makeTempFileSync({ suffix: ".qmd" });64const documentReady = documentContents.replace("!!author!!", name).replace(65"!!template!!",66template,67);68Deno.writeTextFileSync(document, documentReady);69testRender(document, "html", false, [70ensureFileRegexMatches(document, []),71], {72prereq: () => {73console.log(`Testing author '${name}'`);74return Promise.resolve(true);75},76setup: () => {77return Promise.resolve();78},79teardown: () => {80return Deno.remove(document);81},82});83}848586