import { describe, expect, it } from 'vitest' import { checklistNumbers, vatDeadlineLine } from '../checklist' describe('vatDeadlineLine', () => { it('returns null when the company is not VAT-registered', () => { expect( vatDeadlineLine({ vatRegistered: false, momsPeriod: 'quarterly', nextVatDueDate: '2026-11-12' }) ).toBeNull() expect( vatDeadlineLine({ vatRegistered: null, momsPeriod: null, nextVatDueDate: null }) ).toBeNull() }) it('flags the silent zero-deadline misconfiguration when moms_period is unset', () => { expect( vatDeadlineLine({ vatRegistered: true, momsPeriod: null, nextVatDueDate: null }) ).toEqual({ kind: 'missing_period' }) // Even with a stray row, an unset period is still a misconfiguration to surface. expect( vatDeadlineLine({ vatRegistered: true, momsPeriod: undefined, nextVatDueDate: '2026-11-12' }) ).toEqual({ kind: 'missing_period' }) }) it('returns the due date when registered with a period and an upcoming row', () => { expect( vatDeadlineLine({ vatRegistered: true, momsPeriod: 'quarterly', nextVatDueDate: '2026-11-12' }) ).toEqual({ kind: 'date', dueDate: '2026-11-12' }) }) it('says nothing when a period is set but no upcoming row surfaced', () => { expect( vatDeadlineLine({ vatRegistered: true, momsPeriod: 'yearly', nextVatDueDate: null }) ).toBeNull() }) }) describe('checklistNumbers', () => { it('numbers all five steps when both extensions are on', () => { expect(checklistNumbers({ hasSkatteverket: true, hasInbox: true })).toEqual({ count: 5, skv: 3, receipts: 4, assistant: 5, }) }) it('collapses to four steps without the inbox extension', () => { expect(checklistNumbers({ hasSkatteverket: true, hasInbox: false })).toEqual({ count: 4, skv: 3, receipts: 4, assistant: 4, }) }) it('collapses to four steps without the skatteverket extension', () => { expect(checklistNumbers({ hasSkatteverket: false, hasInbox: true })).toEqual({ count: 4, skv: 3, receipts: 3, assistant: 4, }) }) it('collapses to three steps with neither extension', () => { expect(checklistNumbers({ hasSkatteverket: false, hasInbox: false })).toEqual({ count: 3, skv: 3, receipts: 3, assistant: 3, }) }) })