Files
minstrel/web/src/lib/branding.test.ts
T
bvandeusen 180d85eec0 chore(web): post-#363 cleanup — DRY tripwires, drop unused description, singular playlist title
M2 — Add TODO(#375) tripwire comments where the dark/light theme-color
hex pair is duplicated outside tokens.json (vite.config.ts and
applyMetaThemeColor.svelte.ts). Refactoring is out of scope for #363;
the comments are stop signs for the next person who edits these.

M5 — The SPA never reads window.__MINSTREL__.description. The OG meta
description is server-rendered and complete on its own. Drop the dead
inline-script field and the corresponding helpers in branding.ts.
Server-side BrandingConfig.Description stays — it's still used for
<meta name="description"> and og:description.

Copy nit — Playlist detail page title becomes "Playlist · Foo"
matching the singular form already used by Artist · / Album ·.
2026-05-03 19:04:59 -04:00

45 lines
1.4 KiB
TypeScript

import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { appName, pageTitle } from './branding';
const setGlobal = (g: { appName: string } | undefined) => {
if (g === undefined) {
delete (window as { __MINSTREL__?: unknown }).__MINSTREL__;
} else {
(window as { __MINSTREL__?: typeof g }).__MINSTREL__ = g;
}
};
describe('branding helpers', () => {
beforeEach(() => setGlobal(undefined));
afterEach(() => setGlobal(undefined));
it('appName returns the global value when set', () => {
setGlobal({ appName: 'Family Jukebox' });
expect(appName()).toBe('Family Jukebox');
});
it('appName falls back to "Minstrel" when global is undefined', () => {
expect(appName()).toBe('Minstrel');
});
it('appName falls back to "Minstrel" when value contains an unrendered Go token', () => {
setGlobal({ appName: '{{ .AppName }}' });
expect(appName()).toBe('Minstrel');
});
it('pageTitle with section returns "{appName} · {section}"', () => {
setGlobal({ appName: 'Minstrel' });
expect(pageTitle('Search')).toBe('Minstrel · Search');
});
it('pageTitle without section returns just the appName', () => {
setGlobal({ appName: 'Minstrel' });
expect(pageTitle()).toBe('Minstrel');
});
it('pageTitle composes nested sections via the · separator', () => {
setGlobal({ appName: 'Minstrel' });
expect(pageTitle('Library · Artists')).toBe('Minstrel · Library · Artists');
});
});