mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-14 08:53:11 +00:00
- Collection campaignVoteSummarySnapshot (snapshot diário statewide) - Gravação idempotente on-read no loadCampaignHomeSummary + retenção 30d - UI: seta + magnitude ao lado do total B56 (aria-label completo) - Reusa rollup statewide para CG/candidato; assessor vê Δ global (opção A) Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
33 lines
1.4 KiB
TypeScript
33 lines
1.4 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import {
|
|
formatHomeSummaryDeltaMagnitude,
|
|
homeSummaryDeltaAriaLabel,
|
|
resolveHomeSummaryDeltaDirection,
|
|
} from '@/lib/campaignHomeSummaryDelta'
|
|
|
|
describe('campaignHomeSummaryDelta', () => {
|
|
it('classifies direction from signed delta', () => {
|
|
expect(resolveHomeSummaryDeltaDirection(1_500)).toBe('up')
|
|
expect(resolveHomeSummaryDeltaDirection(-200)).toBe('down')
|
|
expect(resolveHomeSummaryDeltaDirection(0)).toBe('flat')
|
|
expect(resolveHomeSummaryDeltaDirection(null)).toBe('unavailable')
|
|
})
|
|
|
|
it('formats magnitude as absolute pt-BR integer votes', () => {
|
|
expect(formatHomeSummaryDeltaMagnitude(12_345)).toBe('12.345')
|
|
expect(formatHomeSummaryDeltaMagnitude(-12_345)).toBe('12.345')
|
|
expect(formatHomeSummaryDeltaMagnitude(null)).toBeNull()
|
|
})
|
|
|
|
it('shows zero magnitude for a flat delta', () => {
|
|
expect(formatHomeSummaryDeltaMagnitude(0)).toBe('0')
|
|
})
|
|
|
|
it('spells out aria labels with direction and magnitude', () => {
|
|
expect(homeSummaryDeltaAriaLabel(500)).toBe('Aumento de 500 votos nos últimos 7 dias')
|
|
expect(homeSummaryDeltaAriaLabel(-500)).toBe('Queda de 500 votos nos últimos 7 dias')
|
|
expect(homeSummaryDeltaAriaLabel(0)).toBe('Sem variação nos últimos 7 dias')
|
|
expect(homeSummaryDeltaAriaLabel(null)).toBe('Variação nos últimos 7 dias indisponível')
|
|
})
|
|
})
|