Files
accounted/lib/invoices/__tests__/unit-labels.test.ts
T
admin e7f0070e84
masterplan-lock / check (push) Successful in 19s
ci / sonar (push) Failing after 21s
security / scan (push) Failing after 1m37s
fix(restore): återställ default branch-filer som raderades av docs-publiceringen (7e33543)
Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i
server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma
strängvärde byggs med konkatenering i stället för att matcha mönstret.
2026-11-10 09:37:22 +01:00

37 lines
1.2 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { unitLabel } from '@/lib/invoices/unit-labels'
describe('unitLabel', () => {
it('maps the editor units to English on an English document', () => {
expect(unitLabel('st', 'en')).toBe('pcs')
expect(unitLabel('tim', 'en')).toBe('h')
expect(unitLabel('dag', 'en')).toBe('day')
expect(unitLabel('månad', 'en')).toBe('month')
})
it('leaves units that are the same in both languages alone', () => {
expect(unitLabel('km', 'en')).toBe('km')
expect(unitLabel('kg', 'en')).toBe('kg')
})
it('prints a Swedish document exactly as stored', () => {
expect(unitLabel('st', 'sv')).toBe('st')
expect(unitLabel('tim', 'sv')).toBe('tim')
})
it('passes user-typed units through untouched', () => {
expect(unitLabel('paket', 'en')).toBe('paket')
expect(unitLabel('m2', 'en')).toBe('m2')
})
it('matches case- and whitespace-insensitively', () => {
expect(unitLabel(' St ', 'en')).toBe('pcs')
expect(unitLabel('TIM', 'en')).toBe('h')
})
it('tolerates a missing unit', () => {
expect(unitLabel(null, 'en')).toBe('')
expect(unitLabel(undefined, 'sv')).toBe('')
})
})