Files
accounted/lib/bookkeeping/__tests__/account-descriptions.test.ts
T
Jakob WennbergandClaude Opus 4.6 ba94f60d06 feat: add review confirmation dialogs and BAS account number tooltips
Add modal review/confirmation dialogs before submitting invoices, supplier
invoices, and journal entries. Since journal entries are legally immutable
once posted, users now see a full summary with an amber warning before
confirming. Add AccountNumber component with rich tooltips showing account
name, class, type, and plain-language Swedish explanation for ~45 key BAS
accounts across all report views.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 15:27:45 +01:00

47 lines
1.7 KiB
TypeScript

import { describe, it, expect } from 'vitest'
import { getAccountDescription, ACCOUNT_DESCRIPTIONS } from '../account-descriptions'
describe('account-descriptions', () => {
describe('getAccountDescription', () => {
it('returns description for known accounts', () => {
const desc = getAccountDescription('1510')
expect(desc).toBeDefined()
expect(desc!.name).toBe('Kundfordringar')
expect(desc!.type).toBe('asset')
})
it('returns undefined for unknown accounts', () => {
expect(getAccountDescription('9999')).toBeUndefined()
expect(getAccountDescription('')).toBeUndefined()
})
})
describe('data completeness', () => {
const KEY_ACCOUNTS = [
'1510', '1930', '2013', '2440', '2611', '2621', '2631',
'2614', '2641', '2645', '2893', '3001', '3002', '3003',
'3305', '3308', '3960', '7960',
]
it.each(KEY_ACCOUNTS)('includes key BAS account %s', (account) => {
expect(getAccountDescription(account)).toBeDefined()
})
it('all entries have non-empty required fields', () => {
for (const [number, desc] of Object.entries(ACCOUNT_DESCRIPTIONS)) {
expect(desc.name, `${number} missing name`).toBeTruthy()
expect(desc.classLabel, `${number} missing classLabel`).toBeTruthy()
expect(desc.type, `${number} missing type`).toBeTruthy()
expect(desc.explanation, `${number} missing explanation`).toBeTruthy()
}
})
it('type values are valid', () => {
const validTypes = ['asset', 'liability', 'equity', 'revenue', 'expense']
for (const [number, desc] of Object.entries(ACCOUNT_DESCRIPTIONS)) {
expect(validTypes, `${number} has invalid type: ${desc.type}`).toContain(desc.type)
}
})
})
})