Skip to content

test(useRecentSearches): verify hook is SSR-safe β€” loadFromStorage handles undefined windowΒ #715

@JhaSourav07

Description

@JhaSourav07

🧩 Background

loadFromStorage in hooks/useRecentSearches.ts guards with typeof window === 'undefined'. This path has no test since jsdom always provides window.

🎯 Objective

Add a test that temporarily removes window to verify the SSR guard.

πŸ“ Files to touch

  • hooks/useRecentSearches.test.ts

πŸ› οΈ Implementation steps

  • Before rendering the hook, temporarily delete global.window.
  • Assert the hook initializes with an empty searches array.
  • Restore global.window after the test.

βœ… Definition of done

  • 1 test case.
  • All existing hook tests pass.

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions