feat: tik op een module om die bovenaan te zetten met een groter temperatuurgetal

Tik op een van de drie binnenmodules zet die bovenaan de lijst (de
overige twee behouden hun onderlinge volgorde) en vergroot alleen het
temperatuurgetal van 50 naar 92px. Nogmaals tikken op de bovenste
(vastgezette) module zet 'm weer los. Puur client-side, geen nieuwe
API-velden: state.pinnedRoomId + de pure functie pinRoom() (met tests)
in format.js. De keuze overleeft de 5-minuten-verversing, reset bij een
volledige herlaad. Servicewerker naar v6.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-13 10:27:09 +02:00
co-authored by Claude Sonnet 5
parent 48d68b86fa
commit 350dafe591
6 changed files with 59 additions and 9 deletions
+22 -1
View File
@@ -121,7 +121,7 @@ test('msUntil computes the wait until the next local time', () => {
import {
co2Level, fPct, fHpa, seriesRange, sparklinePath, sparklinePoints,
windArrowDeg, fKmh, formatHour, formatFullDate,
windArrowDeg, fKmh, formatHour, formatFullDate, pinRoom,
} from '../../public/format.js';
test('co2Level uses the Netatmo thresholds', () => {
@@ -187,3 +187,24 @@ test('formatFullDate matches formatDate for the same calendar date', () => {
assert.equal(formatFullDate('2026-09-14', TZ), 'Maandag 14 september');
assert.equal(formatFullDate('kapot', TZ), '–');
});
test('pinRoom moves the matching room to the front, keeping the others in order', () => {
const rooms = [{ id: 'a' }, { id: 'b' }, { id: 'c' }];
assert.deepEqual(pinRoom(rooms, 'b').map((r) => r.id), ['b', 'a', 'c']);
assert.deepEqual(pinRoom(rooms, 'c').map((r) => r.id), ['c', 'a', 'b']);
});
test('pinRoom returns the original array unchanged without a match, id, or when already first', () => {
const rooms = [{ id: 'a' }, { id: 'b' }];
assert.equal(pinRoom(rooms, null), rooms);
assert.equal(pinRoom(rooms, undefined), rooms);
assert.equal(pinRoom(rooms, 'x'), rooms, 'onbekend id: geen match, ongewijzigd terug');
assert.equal(pinRoom(rooms, 'a'), rooms, 'al vooraan: geen kopie nodig');
});
test('pinRoom does not mutate the input array', () => {
const rooms = [{ id: 'a' }, { id: 'b' }, { id: 'c' }];
const original = rooms.slice();
pinRoom(rooms, 'c');
assert.deepEqual(rooms, original);
});