Files
accounted/lib/company-lookup/__tests__/scb-suggestion.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

38 lines
1.3 KiB
TypeScript

import { describe, it, expect } from 'vitest'
import { toCompanySuggestion } from '../scb-suggestion'
import type { ScbCandidate } from '@/lib/parties/scb/client'
const candidate = (over: Partial<ScbCandidate> = {}): ScbCandidate => ({
orgNumber: '5566778899',
name: 'Testbrand AB',
city: 'Malmö',
industry: null,
legalForm: 'Aktiebolag',
legalFormCode: '49',
status: 'Är verksam',
active: true,
...over,
})
describe('toCompanySuggestion', () => {
it('maps the forms the journey sets up and leaves the rest to the user', () => {
expect(toCompanySuggestion(candidate()).legalEntityType).toBe('AB')
expect(toCompanySuggestion(candidate({ legalFormCode: '10' })).legalEntityType).toBe('EF')
expect(toCompanySuggestion(candidate({ legalFormCode: '61' })).legalEntityType).toBe('Ideell förening')
// Insurance AB, bank AB, ekonomisk förening, stiftelse: not a plain AB.
for (const code of ['42', '41', '51', '72', null]) {
expect(toCompanySuggestion(candidate({ legalFormCode: code })).legalEntityType).toBeNull()
}
})
it('carries only what the picker shows plus the number it resolves to', () => {
expect(toCompanySuggestion(candidate({ active: false }))).toEqual({
orgNumber: '5566778899',
name: 'Testbrand AB',
city: 'Malmö',
legalEntityType: 'AB',
active: false,
})
})
})