Stabilize unit and UI tests for SportsTime
This commit is contained in:
@@ -18,7 +18,7 @@ struct PhotoMetadataTests {
|
||||
// MARK: - Test Data
|
||||
|
||||
private func makeMetadata(
|
||||
captureDate: Date? = Date(),
|
||||
captureDate: Date? = TestClock.now,
|
||||
coordinates: CLLocationCoordinate2D? = CLLocationCoordinate2D(latitude: 40.0, longitude: -74.0)
|
||||
) -> PhotoMetadata {
|
||||
PhotoMetadata(captureDate: captureDate, coordinates: coordinates)
|
||||
@@ -45,7 +45,7 @@ struct PhotoMetadataTests {
|
||||
/// - Expected Behavior: true when captureDate is provided
|
||||
@Test("hasValidDate: true when captureDate provided")
|
||||
func hasValidDate_true() {
|
||||
let metadata = makeMetadata(captureDate: Date())
|
||||
let metadata = makeMetadata(captureDate: TestClock.now)
|
||||
#expect(metadata.hasValidDate == true)
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ struct PhotoMetadataTests {
|
||||
|
||||
@Test("Both valid: location and date both provided")
|
||||
func bothValid() {
|
||||
let metadata = makeMetadata(captureDate: Date(), coordinates: CLLocationCoordinate2D(latitude: 0, longitude: 0))
|
||||
let metadata = makeMetadata(captureDate: TestClock.now, coordinates: CLLocationCoordinate2D(latitude: 0, longitude: 0))
|
||||
#expect(metadata.hasValidLocation == true)
|
||||
#expect(metadata.hasValidDate == true)
|
||||
}
|
||||
@@ -101,7 +101,7 @@ struct PhotoMetadataTests {
|
||||
|
||||
@Test("Only date: coordinates nil")
|
||||
func onlyDate() {
|
||||
let metadata = makeMetadata(captureDate: Date(), coordinates: nil)
|
||||
let metadata = makeMetadata(captureDate: TestClock.now, coordinates: nil)
|
||||
#expect(metadata.hasValidLocation == false)
|
||||
#expect(metadata.hasValidDate == true)
|
||||
}
|
||||
@@ -121,7 +121,7 @@ struct PhotoMetadataTests {
|
||||
/// - Invariant: hasValidDate == (captureDate != nil)
|
||||
@Test("Invariant: hasValidDate equals captureDate check")
|
||||
func invariant_hasValidDateEqualsCaptureCheck() {
|
||||
let withDate = makeMetadata(captureDate: Date())
|
||||
let withDate = makeMetadata(captureDate: TestClock.now)
|
||||
let withoutDate = makeMetadata(captureDate: nil)
|
||||
|
||||
#expect(withDate.hasValidDate == (withDate.captureDate != nil))
|
||||
|
||||
Reference in New Issue
Block a user