| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- import assert from "node:assert/strict";
- import test from "node:test";
- import { createMarkdownRenderer } from "../src/actions/_shared/markdown.js";
- test("route blocks render classes without injected CSS or inline styles", () => {
- const renderer = createMarkdownRenderer({
- resources: {
- routes: {
- "mountain-loop": {
- detail: {
- name: "mountain-loop",
- gpxHref: "/routes/mountain-loop.gpx",
- srcSet: [
- ["/routes/mountain-loop-640.webp", "640w"],
- ["/routes/mountain-loop-1024.webp", "1024w"],
- ],
- aspectRatio: 1.6,
- attribution: "© OpenStreetMap contributors",
- },
- },
- },
- },
- });
- const html = renderer("::route mountain-loop");
- assert.equal(html.includes("<style"), false);
- assert.equal(html.includes(" style="), false);
- assert.equal(html.includes('class="route-block"'), true);
- assert.equal(html.includes('class="route-block__image"'), true);
- assert.equal(html.includes('class="route-block__caption"'), true);
- assert.equal(html.includes('class="route-block__download"'), true);
- assert.equal(html.includes('class="route-block__attribution"'), true);
- assert.equal(html.includes('src="/routes/mountain-loop-640.webp"'), true);
- assert.equal(html.includes('href="/routes/mountain-loop.gpx"'), true);
- assert.equal(html.includes("© OpenStreetMap contributors"), true);
- });
- test("missing route blocks retain classes without inline styles", () => {
- const renderer = createMarkdownRenderer({ resources: {} });
- const html = renderer("::route missing-route");
- assert.equal(
- html,
- '<aside class="route-block route-block--missing">Route not found: missing-route</aside>',
- );
- });
|