config.test.js
922 B · javascript · 18 lines
1import { expect, test } from 'bun:test';2import { HUES, headScript, tintCss } from './config.js';34test('a tint name sets the site accent and still leaves every hue overridable', () => {5 const css = tintCss('purple');6 expect(css).toContain(':root { --accent: var(--purple); }');7 for (const hue of HUES) expect(css).toContain(`:root[data-tint="${hue}"] { --accent: var(--${hue}); }`);8 expect(css.indexOf(':root[data-tint="purple"]')).toBeGreaterThan(css.indexOf(':root { --accent'));9 expect(tintCss(null)).not.toContain(':root { --accent');10});1112test('the head script paints the saved theme, font, tint and saver before the first frame', () => {13 const boot = headScript('cm-');14 expect(boot.startsWith('<script data-boot>')).toBe(true);15 expect(boot).toContain("localStorage.getItem('cm-'+k)");16 expect(boot).toContain("['theme','font','tint','saver']");17 expect(boot).toContain("classList.add('js')");18});