mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 15:19:01 +02:00
feat(test): add test for code block mpapings
This commit is contained in:
parent
a8f9403990
commit
952ec516ee
21
src/services/code_block_theme.spec.ts
Normal file
21
src/services/code_block_theme.spec.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
import { getStylesDirectory, readThemesFromFileSystem } from "./code_block_theme.js";
|
||||||
|
|
||||||
|
import themeNames from "./code_block_theme_names.json" with { type: "json" };
|
||||||
|
|
||||||
|
describe("Code block theme", () => {
|
||||||
|
it("all themes are mapped", () => {
|
||||||
|
const themes = readThemesFromFileSystem(getStylesDirectory());
|
||||||
|
|
||||||
|
const mappedThemeNames = new Set(Object.values(themeNames));
|
||||||
|
const unmappedThemeNames = new Set<string>();
|
||||||
|
|
||||||
|
for (const theme of themes) {
|
||||||
|
if (!mappedThemeNames.has(theme.title)) {
|
||||||
|
unmappedThemeNames.add(theme.title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(unmappedThemeNames.size, `Unmapped themes: ${Array.from(unmappedThemeNames).join(", ")}`).toBe(0);
|
||||||
|
});
|
||||||
|
});
|
@ -44,7 +44,7 @@ export function listSyntaxHighlightingThemes() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStylesDirectory() {
|
export function getStylesDirectory() {
|
||||||
if (isElectron && !isDev) {
|
if (isElectron && !isDev) {
|
||||||
return "styles";
|
return "styles";
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ function getStylesDirectory() {
|
|||||||
* @param path the path to read from. Usually this is the highlight.js `styles` directory.
|
* @param path the path to read from. Usually this is the highlight.js `styles` directory.
|
||||||
* @returns the list of themes.
|
* @returns the list of themes.
|
||||||
*/
|
*/
|
||||||
function readThemesFromFileSystem(path: string): ColorTheme[] {
|
export function readThemesFromFileSystem(path: string): ColorTheme[] {
|
||||||
return fs
|
return fs
|
||||||
.readdirSync(path)
|
.readdirSync(path)
|
||||||
.filter((el) => el.endsWith(".min.css"))
|
.filter((el) => el.endsWith(".min.css"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user