Serverpuls: deutsche Zeitachse und Legende im Diagramm

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-09-30 12:43:13 +00:00
1 parent 16f3150ff1
commit 57f235dd36
3 files changed
+60 -3

No files matched your search

+19 -1
View File
@@ -2,7 +2,7 @@ import test from 'node:test'
import assert from 'node:assert/strict'
import { loadModule } from './load.mjs'
const { formatBytes, formatDelta, ageLabel, usedPct } = await loadModule('src/lib/serverpulsFormat.js')
const { formatBytes, formatDelta, ageLabel, usedPct, axisTimeKind, formatAxisTick, formatLegendTime } = await loadModule('src/lib/serverpulsFormat.js')
test('formatBytes: de-DE, Basis 1024', () => {
assert.equal(formatBytes(1288490189), '1,2 GB')
@@ -34,3 +34,21 @@ test('usedPct: RAM value ist frei', () => {
assert.equal(usedPct(250, 1000), 75)
assert.equal(usedPct(null, 1000), null)
})
test('Zeitachse: Format nach Tick-Abstand', () => {
assert.equal(axisTimeKind(3600), 'time')
assert.equal(axisTimeKind(86400), 'day')
assert.equal(axisTimeKind(86400 * 30), 'month')
assert.equal(axisTimeKind(86400 * 365), 'year')
})
test('Zeitachse: deutsche Ausgabe in Europe/Berlin', () => {
const t = Date.UTC(2026, 8, 30, 9, 20) / 1000 // 11:20 Berlin (MESZ)
assert.equal(formatAxisTick(t, 3600), '11:20')
assert.equal(formatAxisTick(t, 86400 * 2), '30.09.')
assert.equal(formatAxisTick(Date.UTC(2026, 8, 29, 22, 0) / 1000, 3600 * 6), '30.09.') // Mitternacht Berlin
assert.match(formatAxisTick(t, 86400 * 30), /2026/)
assert.equal(formatAxisTick(t, 86400 * 365), '2026')
assert.equal(formatLegendTime(t), '30.09.2026, 11:20')
assert.equal(formatLegendTime(null), '–')
})