feat: add TypeScript types for highlights and sync system
Added highlight system types with strict color and sync status validation: - HighlightColor type with 4 valid colors (yellow, orange, pink, blue) - SyncStatus type for tracking sync state (pending, syncing, synced, error) - BibleHighlight interface with full metadata support - HighlightSyncQueueItem for offline sync queue management - CrossReference interface for verse cross-referencing Includes comprehensive test coverage validating type constraints. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
40
__tests__/types/highlights.test.ts
Normal file
40
__tests__/types/highlights.test.ts
Normal file
@@ -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)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user