diff --git a/__tests__/types/highlights.test.ts b/__tests__/types/highlights.test.ts new file mode 100644 index 0000000..8e382cd --- /dev/null +++ b/__tests__/types/highlights.test.ts @@ -0,0 +1,40 @@ +import { BibleHighlight } from '@/types' + +describe('BibleHighlight types', () => { + it('should create highlight with valid color', () => { + const highlight: BibleHighlight = { + id: 'test-id', + verseId: 'verse-123', + color: 'yellow', + createdAt: Date.now(), + updatedAt: Date.now(), + syncStatus: 'synced' + } + expect(highlight.color).toBe('yellow') + }) + + it('should reject invalid color', () => { + // This test validates TypeScript type checking + const highlight: BibleHighlight = { + id: 'test-id', + verseId: 'verse-123', + // @ts-expect-error - 'red' is not a valid color + color: 'red', + createdAt: Date.now(), + updatedAt: Date.now(), + syncStatus: 'synced' + } + }) + + it('should validate syncStatus types', () => { + const highlight: BibleHighlight = { + id: 'test-id', + verseId: 'verse-123', + color: 'blue', + createdAt: Date.now(), + updatedAt: Date.now(), + syncStatus: 'pending' + } + expect(['pending', 'syncing', 'synced', 'error']).toContain(highlight.syncStatus) + }) +}) diff --git a/types/index.ts b/types/index.ts index 9e87d59..2dbc494 100644 --- a/types/index.ts +++ b/types/index.ts @@ -94,3 +94,33 @@ export interface CacheEntry { timestamp: number expiresAt: number } + +// Highlight system types +export type HighlightColor = 'yellow' | 'orange' | 'pink' | 'blue' +export type SyncStatus = 'pending' | 'syncing' | 'synced' | 'error' + +export interface BibleHighlight { + id: string // UUID + verseId: string + userId?: string // Optional, added by backend + color: HighlightColor + createdAt: number // timestamp + updatedAt: number // timestamp + syncStatus: SyncStatus + syncErrorMsg?: string +} + +export interface HighlightSyncQueueItem { + highlightId: string + action: 'create' | 'update' | 'delete' + highlight: BibleHighlight + retryCount: number +} + +export interface CrossReference { + refVerseId: string + bookName: string + chapter: number + verse: number + preview: string +}