24 lines
1.2 KiB
JavaScript
24 lines
1.2 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import { readFile } from 'node:fs/promises';
|
|
import test from 'node:test';
|
|
|
|
test('Sidebar override renders an accessible no-JavaScript programme switch', async () => {
|
|
const component = await readFile('src/components/ProgrammeSwitch.astro', 'utf8');
|
|
const wrapper = await readFile('src/components/Sidebar.astro', 'utf8');
|
|
assert.match(component, /aria-label="Bachelor programme"/);
|
|
assert.match(component, /aria-current/);
|
|
assert.doesNotMatch(component, /client:|<script/);
|
|
assert.match(wrapper, /@astrojs\/starlight\/components\/Sidebar\.astro/);
|
|
});
|
|
|
|
test('programme switch uses compact visible labels with full accessible names', async () => {
|
|
const component = await readFile('src/components/ProgrammeSwitch.astro', 'utf8');
|
|
assert.match(component, />DSAI<\/a>/);
|
|
assert.match(component, />CS<\/a>/);
|
|
assert.match(component, /aria-label="Data Science & AI"/);
|
|
assert.match(component, /aria-label="Computer Science"/);
|
|
assert.match(component, /title="Data Science & AI"/);
|
|
assert.match(component, /title="Computer Science"/);
|
|
assert.match(component, />Bachelor programme<\/span>/);
|
|
assert.doesNotMatch(component, />Course information<\/span>/);
|
|
});
|