Files
accounted/components/bookkeeping/__tests__/correction-entry-description.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

41 lines
1.6 KiB
TypeScript

import { describe, it, expect } from 'vitest'
import {
autoCorrectionDescription,
correctionDescriptionForSubmit,
} from '@/components/bookkeeping/correction-entry-description'
const ORIGINAL = 'Lån från närstående personer, långfristig del'
describe('autoCorrectionDescription', () => {
it('matches the server-side fallback format', () => {
expect(autoCorrectionDescription(ORIGINAL)).toBe(`Rättelse: ${ORIGINAL}`)
})
})
describe('correctionDescriptionForSubmit', () => {
it('sends nothing when the field still equals the auto prefill', () => {
expect(correctionDescriptionForSubmit(`Rättelse: ${ORIGINAL}`, ORIGINAL)).toBeUndefined()
})
it('sends nothing when the prefill only gained surrounding whitespace', () => {
expect(correctionDescriptionForSubmit(` Rättelse: ${ORIGINAL} `, ORIGINAL)).toBeUndefined()
})
it('sends nothing when the field was cleared (server fallback applies)', () => {
expect(correctionDescriptionForSubmit('', ORIGINAL)).toBeUndefined()
expect(correctionDescriptionForSubmit(' ', ORIGINAL)).toBeUndefined()
})
it('sends a user-edited description (the reported bug: relabel after account change)', () => {
expect(
correctionDescriptionForSubmit('Rättelse: Skulder till närstående personer, kortfristig del', ORIGINAL),
).toBe('Rättelse: Skulder till närstående personer, kortfristig del')
})
it('trims a user-edited description before sending', () => {
expect(correctionDescriptionForSubmit(' Omföring till rätt konto ', ORIGINAL)).toBe(
'Omföring till rätt konto',
)
})
})