test: add unit tests for hooks (useBookmarks, useUpdateCheck)

- Export loadBookmarks/saveBookmarks and isNewer for testability
- Add 12 tests covering bookmark persistence and semver comparison
- Total: 165 tests passing
This commit is contained in:
Nicolas Varrot
2026-02-20 09:04:38 +00:00
parent 295ba7b3e5
commit 3970e8a00c
4 changed files with 92 additions and 3 deletions

View File

@@ -10,7 +10,7 @@ export interface Bookmark {
bookmarkedAt: number;
}
function loadBookmarks(): Bookmark[] {
export function loadBookmarks(): Bookmark[] {
try {
const raw = localStorage.getItem(STORAGE_KEY);
if (raw) return JSON.parse(raw) as Bookmark[];
@@ -18,7 +18,7 @@ function loadBookmarks(): Bookmark[] {
return [];
}
function saveBookmarks(bookmarks: Bookmark[]) {
export function saveBookmarks(bookmarks: Bookmark[]) {
try {
localStorage.setItem(STORAGE_KEY, JSON.stringify(bookmarks));
} catch { /* noop */ }