Browse Source

Fixing tests.

master
Abhi 2 years ago
parent
commit
8a2148c3ca
  1. 2
      Clocker/ClockerUITests/OnboardingTests.swift
  2. 8
      Clocker/ClockerUnitTests/ClockerUnitTests.swift
  3. 4
      Clocker/ClockerUnitTests/SearchDataSourceTests.swift
  4. 8
      Clocker/CoreModelKit/Sources/CoreModelKit/TimezoneData.swift

2
Clocker/ClockerUITests/OnboardingTests.swift

@ -2,7 +2,7 @@
import XCTest
let CLOnboaringTestsLaunchArgument = "isTestingTheOnboardingFlow"
let CLOnboardingTestsLaunchArgument = "isTestingTheOnboardingFlow"
class OnboardingTests: XCTestCase {
var app: XCUIApplication!

8
Clocker/ClockerUnitTests/ClockerUnitTests.swift

@ -170,10 +170,14 @@ class ClockerUnitTests: XCTestCase {
// The below test might fail outside California or if DST is active!
// CI is calibrated to be on LA timezone!
func testTimeDifference() {
XCTAssertTrue(operations.timeDifference() == ", 9h 30m ahead", "Difference was unexpectedly: \(operations.timeDifference())")
let observingDaylightSavings = TimeZone.autoupdatingCurrent.isDaylightSavingTime(for: Date())
let expectedDifference = observingDaylightSavings ? ", 9h 30m ahead" : ", 10h 30m ahead"
let expectedDifferenceForAuckland = observingDaylightSavings ? ", 16h ahead" : ", 18h ahead"
XCTAssertTrue(operations.timeDifference() == expectedDifference, "Difference was unexpectedly: \(operations.timeDifference())")
XCTAssertTrue(californiaOperations.timeDifference() == ", 3h behind", "Difference was unexpectedly: \(californiaOperations.timeDifference())")
XCTAssertTrue(floridaOperations.timeDifference() == "", "Difference was unexpectedly: \(floridaOperations.timeDifference())")
XCTAssertTrue(aucklandOperations.timeDifference() == ", 16h ahead", "Difference was unexpectedly: \(aucklandOperations.timeDifference())")
XCTAssertTrue(aucklandOperations.timeDifference() == expectedDifferenceForAuckland, "Difference was unexpectedly: \(aucklandOperations.timeDifference())")
XCTAssertTrue(omahaOperations.timeDifference() == ", 1h behind", "Difference was unexpectedly: \(omahaOperations.timeDifference())")
}

4
Clocker/ClockerUnitTests/SearchDataSourceTests.swift

@ -106,7 +106,9 @@ class SearchDataSourceTests: XCTestCase {
setupMockData()
let result = subject.retrieveSelectedTimezone(0)
XCTAssert(result.timezone.abbreviation == "PDT")
let possibleOutcomes = Set<String>(["PDT", "PST"])
XCTAssert(possibleOutcomes.contains(result.timezone.abbreviation ?? "NA"),
"Result timezone is actually \(result.timezone.abbreviation ?? "NA")")
}
func testRetrieveSelectedTimezoneWithEmptySearchField() {

8
Clocker/CoreModelKit/Sources/CoreModelKit/TimezoneData.swift

@ -267,6 +267,14 @@ public class TimezoneData: NSObject, NSCoding {
let formatInString = TimezoneData.values[key] ?? DateFormat.twelveHour
return formatInString.contains("ss")
}
public func isDaylightSavings() -> Bool {
guard let timezone = TimeZone(abbreviation: timezone()) else {
return false
}
return timezone.isDaylightSavingTime(for: Date())
}
override public var hash: Int {
guard let placeIdentifier = placeID, let timezone = timezoneID else {

Loading…
Cancel
Save