mana-swift-ui/Tests/ManaComponentsUITests/ManaJobStatusTextTests.swift
Till JS a8621c3ef5 ManaComponentsUI: ManaJobStatusView — Wartezeit-Anzeige für GPU-Jobs
Natives Pendant zu @mana/shared-ui <JobStatus>. + Texthelfer
ManaJobStatusText (9 Tests im neuen Target ManaComponentsUITests).
CHANGELOG trägt zusätzlich den vorbestehenden AutoFill-[Unreleased]-
Eintrag (fremde Arbeit, nur Doku-Text).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-07 15:58:50 +02:00

70 lines
2.3 KiB
Swift

import Testing
@testable import ManaComponentsUI
@Suite("JobStatus-Texthelfer")
struct ManaJobStatusTextTests {
@Test("Sekunden unter einer Minute")
func elapsedUnderMinute() {
#expect(ManaJobStatusText.formatElapsed(0) == "0 s")
#expect(ManaJobStatusText.formatElapsed(45) == "45 s")
#expect(ManaJobStatusText.formatElapsed(59) == "59 s")
}
@Test("Minuten:Sekunden ab 60s")
func elapsedMinutes() {
#expect(ManaJobStatusText.formatElapsed(60) == "1:00 min")
#expect(ManaJobStatusText.formatElapsed(65) == "1:05 min")
#expect(ManaJobStatusText.formatElapsed(750) == "12:30 min")
}
@Test("Negative Werte → 0 s")
func elapsedNegative() {
#expect(ManaJobStatusText.formatElapsed(-5) == "0 s")
}
@Test("Schätzung: typical + max")
func estimateTypicalAndMax() {
#expect(
ManaJobStatusText.formatEstimate(typicalSeconds: 90, maxMinutes: 10)
== "dauert meist etwa 2 Minuten, bei Andrang bis zu 10 Minuten"
)
}
@Test("Schätzung: typical ≤ 60s → unter 1 Minute")
func estimateUnderMinute() {
#expect(
ManaJobStatusText.formatEstimate(typicalSeconds: 60, maxMinutes: 10)
== "dauert meist unter 1 Minute, bei Andrang bis zu 10 Minuten"
)
}
@Test("Schätzung: nur max → Satzanfang")
func estimateMaxOnly() {
#expect(
ManaJobStatusText.formatEstimate(typicalSeconds: nil, maxMinutes: 5)
== "bei Andrang bis zu 5 Minuten"
)
}
@Test("Schätzung: Singular 1 Minute")
func estimateSingular() {
#expect(
ManaJobStatusText.formatEstimate(typicalSeconds: nil, maxMinutes: 1)
== "bei Andrang bis zu 1 Minute"
)
}
@Test("Schätzung: leer ohne Angaben")
func estimateEmpty() {
#expect(ManaJobStatusText.formatEstimate(typicalSeconds: nil, maxMinutes: nil) == "")
}
@Test("Default-Titel pro Zustand")
func defaultTitles() {
#expect(ManaJobStatusText.defaultTitle(.queued) == "In der Warteschlange")
#expect(ManaJobStatusText.defaultTitle(.running) == "Wird bearbeitet")
#expect(ManaJobStatusText.defaultTitle(.done) == "Fertig")
#expect(ManaJobStatusText.defaultTitle(.failed) == "Fehlgeschlagen")
}
}