mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-26 13:05:19 +00:00
Adds static SIDRA demographics, territory-weighted derivation, electorate UI with opt-in copy to manual profiles, shared territory-city resolution, and registers A8+ fill-in debt from capture-review-debts.
53 lines
1.7 KiB
TypeScript
53 lines
1.7 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import {
|
|
getNucleusIbgeVoterProfile,
|
|
IBGE_VOTER_PROFILE_LABEL,
|
|
} from '@/utilities/nucleusIbgeVoterProfile'
|
|
|
|
describe('getNucleusIbgeVoterProfile', () => {
|
|
it('returns a profile for a single municipality', () => {
|
|
const result = getNucleusIbgeVoterProfile({ cities: ['Salvador'], regions: [] })
|
|
expect(result.status).toBe('available')
|
|
if (result.status !== 'available') return
|
|
|
|
expect(result.profile.label).toBe(IBGE_VOTER_PROFILE_LABEL)
|
|
expect(result.profile.notes).toContain('habitantes')
|
|
expect(result.profile.ageRange).toContain('0 a 17 anos')
|
|
expect(result.profile.localTraits).toContain('Predominam moradores')
|
|
expect(result.profile.notes).toContain('município')
|
|
})
|
|
|
|
it('weights multiple municipalities by population', () => {
|
|
const combined = getNucleusIbgeVoterProfile({
|
|
cities: ['Salvador', 'Abaíra'],
|
|
regions: [],
|
|
})
|
|
|
|
expect(combined.status).toBe('available')
|
|
if (combined.status !== 'available') return
|
|
|
|
expect(combined.profile.notes).toContain('2 municípios')
|
|
})
|
|
|
|
it('resolves cities from identity territories when cities are empty', () => {
|
|
const result = getNucleusIbgeVoterProfile({
|
|
cities: [],
|
|
regions: ['Metropolitano de Salvador'],
|
|
})
|
|
|
|
expect(result.status).toBe('available')
|
|
})
|
|
|
|
it('returns semPerfil when geography is missing', () => {
|
|
expect(getNucleusIbgeVoterProfile({ cities: [], regions: [] })).toEqual({
|
|
status: 'semPerfil',
|
|
})
|
|
})
|
|
|
|
it('returns semPerfil for unknown municipalities', () => {
|
|
expect(
|
|
getNucleusIbgeVoterProfile({ cities: ['Município inexistente'], regions: [] }),
|
|
).toEqual({ status: 'semPerfil' })
|
|
})
|
|
})
|