40C3: site structure and 40C3 theme
Move the Hackertours design into a stacked theme (hackertours) on top of upstream zen, and add the 40C3 design as theme layer hackertours-40c3. Adds the tour map, calendar/ICS and list view for the schedule, mobile menu fixes, vendored icons and Leaflet, schedule tests, and README documentation.
This commit is contained in:
parent
b644e8dce2
commit
c18375eeba
1 changed files with 16014 additions and 90 deletions
75
tests/test_schedule.js
Normal file
75
tests/test_schedule.js
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const test = require('node:test');
|
||||
const vm = require('node:vm');
|
||||
|
||||
const script = fs.readFileSync(
|
||||
path.join(__dirname, '../themes/hackertours/assets/js/schedule.js'),
|
||||
'utf8',
|
||||
);
|
||||
|
||||
function runSchedule(today) {
|
||||
const days = new Map();
|
||||
const buttons = Array.from({ length: 5 }, (_, day) => {
|
||||
const id = `day-${day}`;
|
||||
const classes = new Set();
|
||||
days.set(id, {
|
||||
classes,
|
||||
classList: {
|
||||
toggle(name, enabled) {
|
||||
if (enabled) classes.add(name);
|
||||
else classes.delete(name);
|
||||
},
|
||||
},
|
||||
});
|
||||
return {
|
||||
dataset: { date: `2026-12-${26 + day}` },
|
||||
getAttribute: () => id,
|
||||
setAttribute() {},
|
||||
addEventListener(name, callback) {
|
||||
this.click = callback;
|
||||
},
|
||||
};
|
||||
});
|
||||
const picker = { querySelectorAll: () => buttons, hidden: true };
|
||||
const schedule = {
|
||||
querySelector: () => picker,
|
||||
classList: { add() {} },
|
||||
};
|
||||
const document = {
|
||||
querySelectorAll: () => [schedule],
|
||||
getElementById: (id) => days.get(id),
|
||||
};
|
||||
const Date = class {
|
||||
toLocaleDateString() {
|
||||
return today;
|
||||
}
|
||||
};
|
||||
vm.runInNewContext(script, { document, Date });
|
||||
return { buttons, days };
|
||||
}
|
||||
|
||||
test('only past days are hidden during the event, and all return afterwards', () => {
|
||||
const cases = [
|
||||
['2026-12-25', []],
|
||||
['2026-12-26', []],
|
||||
['2026-12-28', [0, 1]],
|
||||
['2026-12-30', [0, 1, 2, 3]],
|
||||
['2026-12-31', []],
|
||||
];
|
||||
for (const [today, expected] of cases) {
|
||||
const { days } = runSchedule(today);
|
||||
const past = [...days.values()]
|
||||
.map((day, index) => day.classes.has('schedule__day--past') ? index : null)
|
||||
.filter((index) => index !== null);
|
||||
assert.deepEqual(past, expected, today);
|
||||
}
|
||||
});
|
||||
|
||||
test('mobile selection can still switch to a past day', () => {
|
||||
const { buttons, days } = runSchedule('2026-12-28');
|
||||
buttons[0].click();
|
||||
assert.ok(days.get('day-0').classes.has('schedule__day--selected'));
|
||||
assert.ok(!days.get('day-2').classes.has('schedule__day--selected'));
|
||||
});
|
||||
Loading…
Reference in a new issue