diff --git a/BDZDelays/bdz-delays/Tests/SearchStationDomainTests/SearchStationDomainTests.swift b/BDZDelays/bdz-delays/Tests/SearchStationDomainTests/SearchStationDomainTests.swift index da11920..a6cc916 100644 --- a/BDZDelays/bdz-delays/Tests/SearchStationDomainTests/SearchStationDomainTests.swift +++ b/BDZDelays/bdz-delays/Tests/SearchStationDomainTests/SearchStationDomainTests.swift @@ -9,9 +9,10 @@ final class SearchStationDomainTests: XCTestCase { let query = "соф" let store = TestStore( - initialState: SearchStationReducer.State(), - reducer: SearchStationReducer(allStations: [.sofia, .dobrich]) - ) + initialState: SearchStationReducer.State() + ) { + SearchStationReducer(allStations: [.sofia, .dobrich]) + } await store.send(.updateQuery(query)) { $0.query = query @@ -23,9 +24,10 @@ final class SearchStationDomainTests: XCTestCase { let query = "asdfg" let store = TestStore( - initialState: SearchStationReducer.State(), - reducer: SearchStationReducer(allStations: [.sofia, .dobrich]) - ) + initialState: SearchStationReducer.State() + ) { + SearchStationReducer(allStations: [.sofia, .dobrich]) + } await store.send(.updateQuery(query)) { $0.query = query @@ -40,9 +42,10 @@ final class SearchStationDomainTests: XCTestCase { ] let store = TestStore( - initialState: SearchStationReducer.State(filteredStations: all), - reducer: SearchStationReducer(allStations: all) - ) + initialState: SearchStationReducer.State(filteredStations: all) + ) { + SearchStationReducer(allStations: all) + } await store.send(.updateQuery(query)) // no modification expected } @@ -52,9 +55,10 @@ final class SearchStationDomainTests: XCTestCase { let store = TestStore( initialState: SearchStationReducer.State( locationStatus: .notYetAskedForAuthorization - ), - reducer: SearchStationReducer() + ) ) { + SearchStationReducer() + } withDependencies: { $0.locationService.requestAuthorization = { await serviceSpy.call() } @@ -73,9 +77,10 @@ final class SearchStationDomainTests: XCTestCase { let store = TestStore( initialState: SearchStationReducer.State( locationStatus: .authorized(nearestStation: nil) - ), - reducer: SearchStationReducer() + ) ) { + SearchStationReducer() + } withDependencies: { $0.locationService.manuallyRefreshStatus = { await serviceSpy.call() } @@ -94,9 +99,10 @@ final class SearchStationDomainTests: XCTestCase { let store = TestStore( initialState: SearchStationReducer.State( locationStatus: .denied - ), - reducer: SearchStationReducer() + ) ) { + SearchStationReducer() + } withDependencies: { $0.settingsService.openSettings = { await serviceSpy.call() } @@ -120,9 +126,10 @@ final class SearchStationDomainTests: XCTestCase { let clock = TestClock() let counter = Spy() let store = TestStore( - initialState: SearchStationReducer.State(), - reducer: SearchStationReducer() + initialState: SearchStationReducer.State() ) { + SearchStationReducer() + } withDependencies: { $0.locationService.statusStream = { AsyncStream { for await _ in clock.timer(interval: .seconds(1)) { @@ -153,9 +160,10 @@ final class SearchStationDomainTests: XCTestCase { let expected: [BGStation] = [.dobrich, .povelyanovo, .sofia] let store = TestStore( - initialState: SearchStationReducer.State(), - reducer: SearchStationReducer() + initialState: SearchStationReducer.State() ) { + SearchStationReducer() + } withDependencies: { $0.favoritesService.loadFavorites = { expected } $0.locationService.statusStream = { AsyncStream { _ in /* never */ } } } @@ -173,9 +181,10 @@ final class SearchStationDomainTests: XCTestCase { let spy = Spy() let store = TestStore( - initialState: SearchStationReducer.State(), - reducer: SearchStationReducer() + initialState: SearchStationReducer.State() ) { + SearchStationReducer() + } withDependencies: { $0.favoritesService.saveFavorites = { _ in await spy.call() } @@ -205,9 +214,10 @@ final class SearchStationDomainTests: XCTestCase { let store = TestStore( initialState: SearchStationReducer.State( favoriteStations: initial - ), - reducer: SearchStationReducer() + ) ) { + SearchStationReducer() + } withDependencies: { $0.favoritesService.saveFavorites = { _ in await spy.call() } diff --git a/BDZDelays/bdz-delays/Tests/StationDomainTests/StationDomainTests.swift b/BDZDelays/bdz-delays/Tests/StationDomainTests/StationDomainTests.swift index b74c6ab..c1d1373 100644 --- a/BDZDelays/bdz-delays/Tests/StationDomainTests/StationDomainTests.swift +++ b/BDZDelays/bdz-delays/Tests/StationDomainTests/StationDomainTests.swift @@ -11,9 +11,10 @@ final class StationDomainTests: XCTestCase { let expected = Self.expectedOne let store = TestStore( - initialState: .init(station: .sofia), - reducer: StationReducer() + initialState: .init(station: .sofia) ) { + StationReducer() + } withDependencies: { $0.stationRepository = StationRepository( fetchTrainsAtStation: { _ in expected } ) @@ -39,9 +40,10 @@ final class StationDomainTests: XCTestCase { loadingState: .loaded, trains: Self.expectedOne, lastUpdateTime: Self.dateOne - ), - reducer: StationReducer() + ) ) { + StationReducer() + } withDependencies: { $0.stationRepository = StationRepository( fetchTrainsAtStation: { _ in throw error } ) @@ -66,9 +68,10 @@ final class StationDomainTests: XCTestCase { loadingState: .loaded, trains: Self.expectedOne, lastUpdateTime: Self.dateOne - ), - reducer: StationReducer() + ) ) { + StationReducer() + } withDependencies: { $0.stationRepository = StationRepository( fetchTrainsAtStation: { _ in expected } ) @@ -94,9 +97,10 @@ final class StationDomainTests: XCTestCase { let store = TestStore( initialState: .init( station: .sofia - ), - reducer: StationReducer() + ) ) { + StationReducer() + } withDependencies: { $0.stationRepository = StationRepository( fetchTrainsAtStation: { _ in let count = await counter.incremented() @@ -139,9 +143,10 @@ final class StationDomainTests: XCTestCase { initialState: .init( station: .sofia, lastUpdateTime: Date(timeIntervalSinceReferenceDate: 51) - ), - reducer: StationReducer() + ) ) { + StationReducer() + } withDependencies: { $0.date.now = dateInNextMinute $0.calendar = Calendar(identifier: .gregorian) $0.stationRepository.fetchTrainsAtStation = { _ in [] } @@ -165,9 +170,10 @@ final class StationDomainTests: XCTestCase { initialState: .init( station: .sofia, lastUpdateTime: Date(timeIntervalSinceReferenceDate: 51) - ), - reducer: StationReducer() + ) ) { + StationReducer() + } withDependencies: { $0.date.now = Date(timeIntervalSinceReferenceDate: 52) $0.calendar = Calendar(identifier: .gregorian) $0.stationRepository.fetchTrainsAtStation = { _ in [] } @@ -183,9 +189,10 @@ final class StationDomainTests: XCTestCase { initialState: .init( station: .sofia, lastUpdateTime: nil - ), - reducer: StationReducer() + ) ) { + StationReducer() + } withDependencies: { $0.date.now = dateInNextMinute $0.calendar = Calendar(identifier: .gregorian) $0.stationRepository.fetchTrainsAtStation = { _ in [] } @@ -212,9 +219,10 @@ final class StationDomainTests: XCTestCase { station: .sofia, loadingState: .failed, lastUpdateTime: Date(timeIntervalSinceReferenceDate: 51) - ), - reducer: StationReducer() + ) ) { + StationReducer() + } withDependencies: { $0.date.now = dateInNextMinute $0.calendar = Calendar(identifier: .gregorian) $0.stationRepository.fetchTrainsAtStation = { _ in [] } @@ -227,9 +235,10 @@ final class StationDomainTests: XCTestCase { let clock = TestClock() let store = TestStore( - initialState: .init(station: .sofia), - reducer: StationReducer() + initialState: .init(station: .sofia) ) { + StationReducer() + } withDependencies: { $0.stationRepository = StationRepository( fetchTrainsAtStation: { _ in for await _ in clock.timer(interval: .seconds(1)) {