-
Notifications
You must be signed in to change notification settings - Fork 0
Testing
ChiefVenzox edited this page Jun 5, 2026
·
1 revision
Run tests from the package root:
swift testNotebookFlowKit includes unit tests for:
- JSON parsing
- supported screen type aliases
- blocked navigation when required answers are missing
- answer collection
- typed answer helpers
- conditional navigation
- route validation
- missing
nextscreen validation
Use NotebookFlowLoader to decode JSON data in tests:
let flow = try NotebookFlowLoader().decode(data)
XCTAssertEqual(flow.name, "StarterFlow")Use FlowStateManager to test navigation without rendering SwiftUI.
let manager = FlowStateManager(flow: flow)
XCTAssertEqual(manager.currentScreen?.id, "welcome")
XCTAssertEqual(manager.advance(), .advanced(to: flow.screens[1]))manager.selectChoice("Fitness", for: "goal")
let event = manager.advance()
guard case .advanced(let screen) = event else {
XCTFail("Expected advanced event")
return
}
XCTAssertEqual(screen.id, "fitness_setup")