Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
import { describe, expect, it } from "vitest";
import { getPresentationThemes, loadPresentationTheme } from "./themes";
describe("Presentation themes", () => {
it("can load all themes", async () => {
const themes = getPresentationThemes();
const stylesheets = await Promise.all(themes.map(theme => loadPresentationTheme(theme.id)));
for (const [ index, stylesheet ] of stylesheets.entries()) {
const id = themes[index].id;
// Every theme drives reveal.js through the custom properties the template emits.
expect(stylesheet, id).toContain("--r-main-font");
expect(stylesheet, id).toContain("--r-background-color");
// The vendored sources carry no fonts: no inlined face, and nothing fetched at render
// time. See reveal-themes/README.md.
expect(stylesheet, id).not.toContain("@font-face");
expect(stylesheet, id).not.toContain("base64");
expect(stylesheet, id).not.toContain("fonts.googleapis.com");
}
});
it("sets the color scheme that matches the background of each theme", async () => {
const darkThemes = [ "black", "black-contrast", "blood", "dracula", "league", "moon", "night" ];
for (const { id, isDark } of getPresentationThemes()) {
const scheme = darkThemes.includes(id) ? "dark" : "light";
expect(isDark, id).toBe(scheme === "dark");
expect(await loadPresentationTheme(id), id).toMatch(
new RegExp(String.raw`\.reveal\s*\{[^}]*color-scheme:\s*${scheme};`));
}
});
it("falls back to the default theme for an unknown name", async () => {
expect(await loadPresentationTheme("no-such-theme")).toBe(await loadPresentationTheme("white"));
});
});