Design P6: reine Helfer fuer Gutschrift-, Angebots- und Speicherzeilen mit Tests
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
910fa0ff30
commit
b81e53eef5
6 files changed
+146
-2
No files matched your search
@@ -0,0 +1,38 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { loadModule } from './load.mjs'
|
||||
|
||||
// P6: Zeilen der Gutschriften (Liste und Detail) als reine Helfer, damit die Seiten keine Inline-Ausdruecke brauchen
|
||||
const { creditStatus, creditActionLabel, creditStatusNote, checkGlyph, checkTone } = await loadModule('src/lib/creditFormat.js')
|
||||
const NB = ' '
|
||||
|
||||
test('creditStatus: Tonnamen und Beschriftungen sind festgelegt', () => {
|
||||
assert.deepEqual(creditStatus('offen'), { tone: 'warn', label: 'Zu prüfen' })
|
||||
assert.deepEqual(creditStatus('rueckfrage'), { tone: 'muted', label: 'Rückfrage beim Kunden' })
|
||||
assert.deepEqual(creditStatus('genehmigt'), { tone: 'ok', label: 'Genehmigt' })
|
||||
assert.deepEqual(creditStatus('abgelehnt'), { tone: 'danger', label: 'Abgelehnt' })
|
||||
assert.deepEqual(creditStatus('neu'), { tone: 'muted', label: 'neu' })
|
||||
})
|
||||
|
||||
test('creditActionLabel: offene und rueckgefragte Antraege werden geprueft, alle anderen angesehen', () => {
|
||||
assert.equal(creditActionLabel('offen'), 'Prüfen')
|
||||
assert.equal(creditActionLabel('rueckfrage'), 'Prüfen')
|
||||
for (const s of ['genehmigt', 'abgelehnt', 'neu', undefined]) assert.equal(creditActionLabel(s), 'Ansehen')
|
||||
})
|
||||
|
||||
test('creditStatusNote: nur genehmigte Antraege tragen Betrag und Buchungsstand', () => {
|
||||
assert.equal(creditStatusNote({ status: 'genehmigt', amountCents: 1250, appliedAt: '2026-10-01T10:00:00Z' }), `12,50${NB}€`)
|
||||
assert.equal(creditStatusNote({ status: 'genehmigt', amountCents: 1250 }), `12,50${NB}€ · nicht gebucht`)
|
||||
assert.equal(creditStatusNote({ status: 'offen', amountCents: 1250 }), '')
|
||||
})
|
||||
|
||||
test('checkGlyph und checkTone: Zeichen und Ton der automatischen Pruefung', () => {
|
||||
assert.equal(checkGlyph('ok'), '✓')
|
||||
assert.equal(checkTone('ok'), 'ok')
|
||||
assert.equal(checkGlyph('warn'), '!')
|
||||
assert.equal(checkTone('warn'), 'warn')
|
||||
assert.equal(checkGlyph('info'), 'i')
|
||||
assert.equal(checkTone('info'), 'info')
|
||||
assert.equal(checkGlyph(undefined), 'i')
|
||||
assert.equal(checkTone(undefined), 'muted')
|
||||
})
|
||||
Reference in new issue
Block a user