Skip to content

test: add comprehensive tests for ReaderEngine#18

Merged
gvonness-apolitical merged 1 commit intomainfrom
test/reader-engine
Feb 3, 2026
Merged

test: add comprehensive tests for ReaderEngine#18
gvonness-apolitical merged 1 commit intomainfrom
test/reader-engine

Conversation

@gvonness-apolitical
Copy link
Collaborator

Summary

Adds comprehensive unit tests for the ReaderEngine, testing core orchestration logic.

Tests Added (23)

init() with src

  • Load document from URL source
  • Load document from File source
  • Call onReady callback when loaded
  • Call onPageChange callback
  • Handle validation errors
  • Error when no src or manifest provided

init() with manifest

  • Load manifest and first chapter
  • Handle invalid format in first chapter

Navigation

  • Call next() on reader
  • Call prev() on reader
  • Do nothing if no reader

Manifest Navigation

  • Go to next chapter when at last page
  • Go to previous chapter when at first page

Getters

  • Return navigation from reader
  • Return current format
  • Return false for hasManifest when not using manifest
  • Return null for manifest controller when not using manifest

Error Handling

  • Show error state for DRM protected files
  • Show retry button for retryable errors
  • Handle unknown errors

updateProgress

  • Update loading progress display

destroy

  • Clean up all resources
  • Destroy manifest controller if present

Impact

  • Test count: 191 → 214 (+23 tests)
  • New test file: 388 lines

Test plan

  • All 214 tests pass
  • Build succeeds

ReaderEngine tests (23):
- init() with src - URL and File loading, callbacks
- init() with manifest - chapter loading
- Error handling - validation errors, unknown errors
- Navigation - next/prev with and without manifest
- Manifest navigation - chapter transitions at boundaries
- Getters - getNavigation, getFormat, hasManifest
- updateProgress - loading progress display
- destroy - resource cleanup

Increases test count from 191 to 214 (+23 tests)
@gvonness-apolitical gvonness-apolitical merged commit 3d8fb41 into main Feb 3, 2026
3 checks passed
@gvonness-apolitical gvonness-apolitical deleted the test/reader-engine branch February 3, 2026 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant