feat(ui): humidity, CO2 pill per room and 24h pressure sparkline
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -118,3 +118,36 @@ test('msUntil computes the wait until the next local time', () => {
|
||||
assert.equal(msUntil(now, TZ, 15), (28 * 60 - 5) * 1000 - 500);
|
||||
assert.equal(msUntil(new Date('2026-09-11T22:00:00.000Z'), TZ, 0), 86400000, 'precies op het moment zelf: pas morgen weer');
|
||||
});
|
||||
|
||||
import { co2Level, fPct, fHpa, seriesRange, sparklinePath } from '../../public/format.js';
|
||||
|
||||
test('co2Level uses the Netatmo thresholds', () => {
|
||||
assert.deepEqual(co2Level(612), { level: 'good', label: 'goed' });
|
||||
assert.deepEqual(co2Level(1000), { level: 'good', label: 'goed' });
|
||||
assert.deepEqual(co2Level(1001), { level: 'medium', label: 'matig' });
|
||||
assert.deepEqual(co2Level(1500), { level: 'medium', label: 'matig' });
|
||||
assert.deepEqual(co2Level(1501), { level: 'bad', label: 'slecht' });
|
||||
assert.deepEqual(co2Level(null), { level: 'unknown', label: '–' });
|
||||
});
|
||||
|
||||
test('fPct and fHpa', () => {
|
||||
assert.equal(fPct(48), '48%');
|
||||
assert.equal(fPct(47.6), '48%');
|
||||
assert.equal(fPct(null), '–');
|
||||
assert.equal(fHpa(1014.2), '1014 hPa');
|
||||
assert.equal(fHpa(null), '–');
|
||||
});
|
||||
|
||||
test('seriesRange ignores nulls', () => {
|
||||
assert.deepEqual(seriesRange([1010, null, 1015.5, 1008]), { min: 1008, max: 1015.5 });
|
||||
assert.equal(seriesRange([null, undefined]), null);
|
||||
});
|
||||
|
||||
test('sparklinePath scales points into the box', () => {
|
||||
assert.equal(sparklinePath([1000, 1010, 1005], 100, 50, 0), 'M0.0,50.0 L50.0,0.0 L100.0,25.0');
|
||||
assert.equal(sparklinePath([1000, 1010], 100, 50, 5), 'M5.0,45.0 L95.0,5.0');
|
||||
assert.equal(sparklinePath([1010, 1010, 1010], 100, 50, 0), 'M0.0,25.0 L50.0,25.0 L100.0,25.0', 'vlakke reeks in het midden');
|
||||
assert.equal(sparklinePath([1000, null, 1010], 100, 50, 0), 'M0.0,50.0 L100.0,0.0', 'null-punt overgeslagen');
|
||||
assert.equal(sparklinePath([1000], 100, 50), '');
|
||||
assert.equal(sparklinePath([], 100, 50), '');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user