Also disables Vitest file parallelism since concurrent astro builds across test files raced on the shared dist/ output.
36 lines
1.4 KiB
TypeScript
36 lines
1.4 KiB
TypeScript
import { describe, it, expect, beforeAll } from 'vitest';
|
|
import { execSync } from 'node:child_process';
|
|
import { readFileSync } from 'node:fs';
|
|
|
|
describe('Header, language switcher, theme toggle', () => {
|
|
beforeAll(() => {
|
|
execSync('npm run build', { stdio: 'inherit' });
|
|
});
|
|
|
|
it('renders the brand link on both locales', () => {
|
|
const en = readFileSync('dist/en/index.html', 'utf-8');
|
|
const fr = readFileSync('dist/fr/index.html', 'utf-8');
|
|
expect(en).toContain('class="brand" href="/en/"');
|
|
expect(fr).toContain('class="brand" href="/fr/"');
|
|
});
|
|
|
|
it('language switcher on /en/ links to /fr/ and vice versa', () => {
|
|
const en = readFileSync('dist/en/index.html', 'utf-8');
|
|
const fr = readFileSync('dist/fr/index.html', 'utf-8');
|
|
expect(en).toContain('class="language-switcher" href="/fr/"');
|
|
expect(fr).toContain('class="language-switcher" href="/en/"');
|
|
});
|
|
|
|
it('theme toggle button carries localized aria-labels', () => {
|
|
const en = readFileSync('dist/en/index.html', 'utf-8');
|
|
const fr = readFileSync('dist/fr/index.html', 'utf-8');
|
|
expect(en).toContain('aria-label="Switch to dark mode"');
|
|
expect(fr).toContain('aria-label="Passer en mode sombre"');
|
|
});
|
|
|
|
it('theme toggle click handler flips data-theme and persists to localStorage', () => {
|
|
const en = readFileSync('dist/en/index.html', 'utf-8');
|
|
expect(en).toContain("localStorage.setItem('ombrora-theme', next)");
|
|
});
|
|
});
|