68 lines
3.3 KiB
JavaScript
68 lines
3.3 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { filterResolvedSidebar, programmeForPathname, programmeSwitchTargets, sidebarForPathname } from '../src/config/programme-navigation.mjs';
|
|
|
|
test('programme routes identify the active bachelor programme', () => {
|
|
assert.equal(programmeForPathname('/computer-science/year-1/'), 'computer-science');
|
|
assert.equal(programmeForPathname('/data-science-and-ai/year-2/'), 'data-science-and-ai');
|
|
assert.equal(programmeForPathname('/useful-information/'), null);
|
|
});
|
|
|
|
test('programme routes retain only the selected curriculum and shared destinations', () => {
|
|
const computerScience = JSON.stringify(sidebarForPathname('/computer-science/year-1/'));
|
|
assert.match(computerScience, /"label":"Home"/);
|
|
assert.match(computerScience, /previous-exams-and-documents/);
|
|
assert.match(computerScience, /"label":"Computer Science"/);
|
|
assert.match(computerScience, /"label":"Useful Information"/);
|
|
assert.doesNotMatch(computerScience, /"label":"Data Science & AI"/);
|
|
assert.doesNotMatch(computerScience, /"label":"About Incognito"/);
|
|
assert.doesNotMatch(computerScience, /"label":"Master AI"/);
|
|
assert.doesNotMatch(computerScience, /"label":"Master DSDM"/);
|
|
|
|
const dataScience = JSON.stringify(sidebarForPathname('/data-science-and-ai/year-2/'));
|
|
assert.match(dataScience, /"label":"Home"/);
|
|
assert.match(dataScience, /previous-exams-and-documents/);
|
|
assert.match(dataScience, /"label":"Data Science & AI"/);
|
|
assert.match(dataScience, /"label":"Useful Information"/);
|
|
assert.doesNotMatch(dataScience, /"label":"Computer Science"/);
|
|
assert.doesNotMatch(dataScience, /"label":"About Incognito"/);
|
|
assert.doesNotMatch(dataScience, /"label":"Master AI"/);
|
|
assert.doesNotMatch(dataScience, /"label":"Master DSDM"/);
|
|
});
|
|
|
|
test('global routes retain the existing global navigation', () => {
|
|
const global = JSON.stringify(sidebarForPathname('/useful-information/'));
|
|
assert.match(global, /"label":"About Incognito"/);
|
|
assert.match(global, /"label":"Master AI"/);
|
|
assert.match(global, /"label":"Master DSDM"/);
|
|
assert.match(global, /"label":"Bachelor programmes"/);
|
|
});
|
|
|
|
test('resolved programme sidebars use the same focused groups', () => {
|
|
const entries = [
|
|
{ label: 'Home' },
|
|
{ label: 'About Incognito' },
|
|
{ label: 'Previous exams and documents' },
|
|
{ label: 'Computer Science' },
|
|
{ label: 'Data Science & AI' },
|
|
{ label: 'Master AI' },
|
|
{ label: 'Master DSDM' },
|
|
{ label: 'Useful Information' },
|
|
];
|
|
|
|
assert.deepEqual(
|
|
filterResolvedSidebar(entries, '/computer-science/').map(({ label }) => label),
|
|
['Home', 'Previous exams and documents', 'Computer Science', 'Useful Information'],
|
|
);
|
|
assert.deepEqual(
|
|
filterResolvedSidebar(entries, '/data-science-and-ai/').map(({ label }) => label),
|
|
['Home', 'Previous exams and documents', 'Data Science & AI', 'Useful Information'],
|
|
);
|
|
assert.deepEqual(filterResolvedSidebar(entries, '/useful-information/'), entries);
|
|
});
|
|
|
|
test('shared course switches to its paired programme route', () => {
|
|
const targets = programmeSwitchTargets('/computer-science/year-1/period-2/calculus/');
|
|
assert.equal(targets.dataScience, '/data-science-and-ai/year-1/block-2/calculus/');
|
|
assert.equal(targets.computerScience, '/computer-science/year-1/period-2/calculus/');
|
|
});
|