Skip to content

Commit af1274e

Browse files
authored
test(useRecentSearches): add persistence across re-renders test (JhaSourav07#773)
## Description Fixes JhaSourav07#718 ## Pillar - [] 🎨 Pillar 1 β€” New Theme Design - [] πŸ“ Pillar 2 β€” Geometric SVG Improvement - [] πŸ• Pillar 3 β€” Timezone Logic Optimization - [x] πŸ› οΈ Other (Bug fix, refactoring, docs) ## Visual Preview ## Checklist before requesting a review: - [x] I have read the `CONTRIBUTING.md` file. - [x] I have tested these changes locally (`localhost:3000/api/streak?user=YOUR_USERNAME`). - [x] I have run `npm run format` and `npm run lint` locally and resolved all errors (CI will fail otherwise). - [x] My commits follow the Conventional Commits format (e.g., `feat(themes): ...`, `fix(calculate): ...`). - [] I have updated `README.md` if I added a new theme or URL parameter. - [x] I have started the repo. - [x] I have made sure that i have only one commit to merge in this PR. - [] The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts). - [x] (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.
2 parents afaf693 + ab66a1e commit af1274e

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

β€Žhooks/useRecentSearches.test.tsβ€Ž

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,14 @@ describe('useRecentSearches', () => {
7272
});
7373
expect(result.current.searches).toEqual([]);
7474
});
75+
76+
it('persists searches across remounts', () => {
77+
const { result, unmount } = renderHook(() => useRecentSearches());
78+
act(() => {
79+
result.current.addSearch('octocat');
80+
});
81+
unmount();
82+
const { result: result2 } = renderHook(() => useRecentSearches());
83+
expect(result2.current.searches[0]).toBe('octocat');
84+
});
7585
});

0 commit comments

Comments
Β (0)