teqo-backup/tests/unit/homeSearchFocusHistory.unit.spec.ts
Cursor Agent 84365ddf54
B106 — Voltar no header mobile, Android back e skeleton das sugestões
- CampaignHomeSearchChromeContext + publisher no Início
- CampaignMobileTopBar troca SidebarTrigger por Voltar quando uiFocused
- useHomeSearchFocusHistory com pushState/popstate para back do SO
- HomeSearchSuggestSkeleton enquanto isFetching sem hits
- Unit tests para history helper, top bar e skeleton

Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
2026-08-01 18:36:28 +00:00

38 lines
1 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import {
HOME_SEARCH_FOCUS_HISTORY_KEY,
isHomeSearchFocusHistoryState,
shouldCollapseHomeSearchOnPopstate,
} from '@/lib/homeSearchFocusHistory'
describe('homeSearchFocusHistory', () => {
it('recognizes the focus history mark', () => {
expect(isHomeSearchFocusHistoryState({ [HOME_SEARCH_FOCUS_HISTORY_KEY]: true })).toBe(true)
expect(isHomeSearchFocusHistoryState({})).toBe(false)
expect(isHomeSearchFocusHistoryState(null)).toBe(false)
})
it('collapses on popstate only when focus history was pushed by us', () => {
expect(
shouldCollapseHomeSearchOnPopstate({
wasHistoryPushed: true,
closingProgrammatically: false,
}),
).toBe(true)
expect(
shouldCollapseHomeSearchOnPopstate({
wasHistoryPushed: true,
closingProgrammatically: true,
}),
).toBe(false)
expect(
shouldCollapseHomeSearchOnPopstate({
wasHistoryPushed: false,
closingProgrammatically: false,
}),
).toBe(false)
})
})