-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
110 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 0 additions & 90 deletions
90
CriticalMapsKit/Tests/NextRideFeatureTests/RideTests.swift
This file was deleted.
Oops, something went wrong.
63 changes: 63 additions & 0 deletions
63
CriticalMapsKit/Tests/NextRideFeatureTests/RideTimeTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import ComposableArchitecture | ||
import Helpers | ||
import SharedModels | ||
import Foundation | ||
import Testing | ||
|
||
struct RideTimeTests { | ||
@Test("Ride in new york timezone") | ||
func rideWithNewYorkTimezone() { | ||
withDependencies { | ||
$0.locale = Locale(identifier: "en_US") | ||
} operation: { | ||
let ride = Ride.mock(timeZone: .newYork, timestamp: 1727478000) | ||
let rideTime = ride.rideTime | ||
#expect(rideTime == "7:00 PM") | ||
} | ||
} | ||
|
||
@Test("Ride in berlin timezone") | ||
func rideWithBerlinTimezone() { | ||
withDependencies { | ||
$0.locale = Locale(identifier: "de_DE") | ||
} operation: { | ||
let ride = Ride.mock(timeZone: .germany, timestamp: 1725192000) | ||
let rideTime = ride.rideTime | ||
#expect(rideTime == "14:00") | ||
} | ||
} | ||
|
||
@Test("Ride in GMT timezone") | ||
func rideWithGMTTimezone() { | ||
withDependencies { | ||
$0.locale = Locale(identifier: "pt_PT") | ||
} operation: { | ||
let ride = Ride.mock(timeZone: .gmt, timestamp: 1727452800) | ||
let rideTime = ride.rideTime | ||
#expect(rideTime == "16:00") | ||
} | ||
} | ||
} | ||
|
||
private extension Ride { | ||
static func mock(timeZone: TimeZone, timestamp: TimeInterval) -> Self { | ||
Self( | ||
id: 0, | ||
city: Ride.City(id: 1, name: "Berlin", timezone: timeZone.identifier), | ||
slug: nil, | ||
title: "CriticalMaps Berlin", | ||
description: nil, | ||
dateTime: Date(timeIntervalSince1970: timestamp), | ||
location: nil, | ||
latitude: 53.1235, | ||
longitude: 13.4234, | ||
estimatedParticipants: nil, | ||
estimatedDistance: nil, | ||
estimatedDuration: nil, | ||
enabled: true, | ||
disabledReason: nil, | ||
disabledReasonMessage: nil, | ||
rideType: .criticalMass | ||
) | ||
} | ||
} |