- Enable zoom/pan on progress map with reset button - Add visit count badges to stadium chips - Create GamesHistoryView with year grouping and sport filters - Create StadiumVisitHistoryView for viewing all visits to a stadium - Add VisitListCard and GamesHistoryRow components - Add "See All" navigation from Recent Visits to Games History - Add tests for map interactions, visit lists, and games history Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
49 lines
1.8 KiB
Swift
49 lines
1.8 KiB
Swift
import XCTest
|
|
import MapKit
|
|
@testable import SportsTime
|
|
|
|
final class ProgressMapViewTests: XCTestCase {
|
|
|
|
@MainActor
|
|
func test_MapViewModel_TracksUserInteraction() {
|
|
// Given: A map view model
|
|
let viewModel = MapInteractionViewModel()
|
|
|
|
// When: User interacts with map (zoom/pan)
|
|
viewModel.userDidInteract()
|
|
|
|
// Then: Interaction is tracked
|
|
XCTAssertTrue(viewModel.hasUserInteracted, "Should track user interaction")
|
|
XCTAssertTrue(viewModel.shouldShowResetButton, "Should show reset button after interaction")
|
|
}
|
|
|
|
@MainActor
|
|
func test_MapViewModel_ResetClearsInteraction() {
|
|
// Given: A map with user interaction
|
|
let viewModel = MapInteractionViewModel()
|
|
viewModel.userDidInteract()
|
|
|
|
// When: User resets the view
|
|
viewModel.resetToDefault()
|
|
|
|
// Then: Interaction flag is cleared
|
|
XCTAssertFalse(viewModel.hasUserInteracted, "Should clear interaction flag after reset")
|
|
XCTAssertFalse(viewModel.shouldShowResetButton, "Should hide reset button after reset")
|
|
}
|
|
|
|
@MainActor
|
|
func test_MapViewModel_ZoomToStadium_SetsCorrectRegion() {
|
|
// Given: A map view model
|
|
let viewModel = MapInteractionViewModel()
|
|
|
|
// When: Zooming to a stadium location
|
|
let stadiumCoord = CLLocationCoordinate2D(latitude: 40.8296, longitude: -73.9262) // Yankee Stadium
|
|
viewModel.zoomToStadium(at: stadiumCoord)
|
|
|
|
// Then: Region is set to city-level zoom
|
|
XCTAssertEqual(viewModel.region.center.latitude, stadiumCoord.latitude, accuracy: 0.001)
|
|
XCTAssertEqual(viewModel.region.center.longitude, stadiumCoord.longitude, accuracy: 0.001)
|
|
XCTAssertEqual(viewModel.region.span.latitudeDelta, 0.01, accuracy: 0.005, "Should use city-level zoom span")
|
|
}
|
|
}
|