refactor(tests): TDD rewrite of all unit tests with spec documentation
Complete rewrite of unit test suite using TDD methodology: Planning Engine Tests: - GameDAGRouterTests: Beam search, anchor games, transitions - ItineraryBuilderTests: Stop connection, validators, EV enrichment - RouteFiltersTests: Region, time window, scoring filters - ScenarioA/B/C/D PlannerTests: All planning scenarios - TravelEstimatorTests: Distance, duration, travel days - TripPlanningEngineTests: Orchestration, caching, preferences Domain Model Tests: - AchievementDefinitionsTests, AnySportTests, DivisionTests - GameTests, ProgressTests, RegionTests, StadiumTests - TeamTests, TravelSegmentTests, TripTests, TripPollTests - TripPreferencesTests, TripStopTests, SportTests Service Tests: - FreeScoreAPITests, RouteDescriptionGeneratorTests - SuggestedTripsGeneratorTests Export Tests: - ShareableContentTests (card types, themes, dimensions) Bug fixes discovered through TDD: - ShareCardDimensions: mapSnapshotSize exceeded available width (960x480) - ScenarioBPlanner: Added anchor game validation filter All tests include: - Specification tests (expected behavior) - Invariant tests (properties that must always hold) - Edge case tests (boundary conditions) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
48
SportsTimeTests/Services/DataProviderTests.swift
Normal file
48
SportsTimeTests/Services/DataProviderTests.swift
Normal file
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// DataProviderTests.swift
|
||||
// SportsTimeTests
|
||||
//
|
||||
// TDD specification tests for DataProvider types.
|
||||
//
|
||||
|
||||
import Testing
|
||||
import Foundation
|
||||
@testable import SportsTime
|
||||
|
||||
// MARK: - DataProviderError Tests
|
||||
|
||||
@Suite("DataProviderError")
|
||||
struct DataProviderErrorTests {
|
||||
|
||||
// MARK: - Specification Tests: errorDescription
|
||||
|
||||
/// - Expected Behavior: contextNotConfigured has meaningful error message
|
||||
@Test("errorDescription: contextNotConfigured mentions configuration")
|
||||
func errorDescription_contextNotConfigured() {
|
||||
let error = DataProviderError.contextNotConfigured
|
||||
#expect(error.errorDescription != nil)
|
||||
#expect(error.errorDescription!.lowercased().contains("configured") || error.errorDescription!.lowercased().contains("context"))
|
||||
}
|
||||
|
||||
/// - Expected Behavior: error conforms to LocalizedError
|
||||
@Test("DataProviderError: conforms to LocalizedError")
|
||||
func dataProviderError_localizedError() {
|
||||
let error: any LocalizedError = DataProviderError.contextNotConfigured
|
||||
#expect(error.errorDescription != nil)
|
||||
}
|
||||
|
||||
// MARK: - Invariant Tests
|
||||
|
||||
/// - Invariant: All errors have non-empty descriptions
|
||||
@Test("Invariant: all errors have descriptions")
|
||||
func invariant_allHaveDescriptions() {
|
||||
let errors: [DataProviderError] = [
|
||||
.contextNotConfigured
|
||||
]
|
||||
|
||||
for error in errors {
|
||||
#expect(error.errorDescription != nil)
|
||||
#expect(!error.errorDescription!.isEmpty)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user