// // MapSnapshotServiceTests.swift // SportsTimeTests // // TDD specification tests for MapSnapshotService types. // import Testing import Foundation @testable import SportsTime // MARK: - MapSnapshotError Tests @Suite("MapSnapshotError") struct MapSnapshotErrorTests { // MARK: - Specification Tests: errorDescription /// - Expected Behavior: noStops explains no stops provided @Test("errorDescription: noStops mentions stops") func errorDescription_noStops() { let error = MapSnapshotService.MapSnapshotError.noStops #expect(error.errorDescription != nil) #expect(error.errorDescription!.lowercased().contains("stop") || error.errorDescription!.lowercased().contains("no")) } /// - Expected Behavior: snapshotFailed includes the reason @Test("errorDescription: snapshotFailed includes reason") func errorDescription_snapshotFailed() { let error = MapSnapshotService.MapSnapshotError.snapshotFailed("Test reason") #expect(error.errorDescription != nil) #expect(error.errorDescription!.contains("Test reason") || error.errorDescription!.lowercased().contains("snapshot")) } /// - Expected Behavior: invalidCoordinates explains the issue @Test("errorDescription: invalidCoordinates mentions coordinates") func errorDescription_invalidCoordinates() { let error = MapSnapshotService.MapSnapshotError.invalidCoordinates #expect(error.errorDescription != nil) #expect(error.errorDescription!.lowercased().contains("coordinate") || error.errorDescription!.lowercased().contains("invalid")) } // MARK: - Invariant Tests /// - Invariant: All errors have non-empty descriptions @Test("Invariant: all errors have descriptions") func invariant_allHaveDescriptions() { let errors: [MapSnapshotService.MapSnapshotError] = [ .noStops, .snapshotFailed("test"), .invalidCoordinates ] for error in errors { #expect(error.errorDescription != nil) #expect(!error.errorDescription!.isEmpty) } } /// - Invariant: snapshotFailed preserves the reason message @Test("Invariant: snapshotFailed preserves reason") func invariant_snapshotFailedPreservesReason() { let testReason = "Network timeout 12345" let error = MapSnapshotService.MapSnapshotError.snapshotFailed(testReason) #expect(error.errorDescription!.contains(testReason)) } }