mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-13 15:13:07 +00:00
- Allow horizontal bleed on home-actions retraction shell (overflow-y-hidden instead of overflow-hidden) so -mx-4 is not clipped by the chrome wrapper. - Hide HomeSummaryDelta chip and period caption when delta is 0 or null; add shouldShowHomeSummaryDelta helper and unit pins. Closes #150 Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
41 lines
1.7 KiB
TypeScript
41 lines
1.7 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import {
|
|
formatHomeSummaryDeltaMagnitude,
|
|
homeSummaryDeltaAriaLabel,
|
|
resolveHomeSummaryDeltaDirection,
|
|
shouldShowHomeSummaryDelta,
|
|
} 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')
|
|
})
|
|
|
|
it('shows the delta chip only when movement occurred', () => {
|
|
expect(shouldShowHomeSummaryDelta(500)).toBe(true)
|
|
expect(shouldShowHomeSummaryDelta(-200)).toBe(true)
|
|
expect(shouldShowHomeSummaryDelta(0)).toBe(false)
|
|
expect(shouldShowHomeSummaryDelta(null)).toBe(false)
|
|
})
|
|
})
|