|
1 | | -import { expect, test } from "vitest"; |
2 | | -import { SCAD_EXT, THEMES } from "../../src/core"; |
| 1 | +import path from "node:path"; |
| 2 | +import { describe, expect, test } from "vitest"; |
3 | 3 | import { createTestInstance } from "../_setup/eleventy"; |
| 4 | +import type { EleventyDirs, ModelViewerTheme } from "../../src"; |
4 | 5 |
|
5 | | -const CASES = THEMES.map((t) => [t]); |
| 6 | +const CASES: ModelViewerTheme[][] = [ |
| 7 | + ["Traditional"], |
| 8 | + ["Modernist"], |
| 9 | + ["Midnight"], |
| 10 | + ["Chocolate"], |
| 11 | + ["Oldstyle"], |
| 12 | + ["Steely"], |
| 13 | + ["Swiss"], |
| 14 | + ["Ultramarine"], |
| 15 | +]; |
6 | 16 |
|
7 | | -test("invalid theme throws an error", async () => { |
8 | | - await expect(async () => { |
9 | | - // @ts-expect-error |
10 | | - const eleventy = createTestInstance({ theme: "TacoBell#324" }); |
11 | | - await eleventy.toJSON(); |
12 | | - }).rejects.toThrow("Error processing the `EleventyPluginOpenSCAD` plugin"); |
13 | | -}); |
14 | | - |
15 | | -test.each(CASES)("%s", async (theme) => { |
| 17 | +describe.for(CASES)("Theme: %s", async ([theme]) => { |
16 | 18 | const eleventy = createTestInstance({ |
17 | 19 | launchPath: "docker", |
18 | 20 | resolveLaunchPath: false, |
19 | 21 | theme: theme, |
20 | 22 | silent: true, |
21 | 23 | noSTL: true, |
22 | 24 | }); |
| 25 | + |
23 | 26 | const pages = await eleventy.toJSON(); |
24 | | - const scadPages = pages.filter((p) => p.inputPath.endsWith(SCAD_EXT)); |
25 | 27 |
|
26 | | - for (const page of scadPages) { |
27 | | - const themeURL = `https://www.w3.org/StyleSheets/Core/${theme}`; |
28 | | - expect(page.content).includes(themeURL); |
| 28 | + for (const page of pages) { |
| 29 | + const relativeSTL = path.relative( |
| 30 | + (eleventy.directories as EleventyDirs).output, |
| 31 | + page.outputPath, |
| 32 | + ); |
| 33 | + test(`CSS: ${relativeSTL}`, () => { |
| 34 | + const themeURL = `https://www.w3.org/StyleSheets/Core/${theme}`; |
| 35 | + expect(page.content).includes(themeURL); |
| 36 | + }); |
29 | 37 | } |
30 | 38 | }); |
| 39 | + |
| 40 | +test("invalid theme throws an error", async () => { |
| 41 | + await expect(async () => { |
| 42 | + // @ts-expect-error |
| 43 | + const eleventy = createTestInstance({ theme: "TacoBell#324" }); |
| 44 | + await eleventy.toJSON(); |
| 45 | + }).rejects.toThrow("Error processing the `EleventyPluginOpenSCAD` plugin"); |
| 46 | +}); |
0 commit comments