|
|
@ -108,6 +108,17 @@ class ClockerUnitTests: XCTestCase { |
|
|
|
XCTAssert(newDefaults?.count == oldCount + 1) |
|
|
|
XCTAssert(newDefaults?.count == oldCount + 1) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func testDecoding() { |
|
|
|
|
|
|
|
let timezone = TimezoneData.customObject(from: nil) |
|
|
|
|
|
|
|
XCTAssertNotNil(timezone) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func testDescription() { |
|
|
|
|
|
|
|
let timezoneData = TimezoneData(with: california) |
|
|
|
|
|
|
|
XCTAssertFalse(timezoneData.description.isEmpty) |
|
|
|
|
|
|
|
XCTAssertFalse(timezoneData.debugDescription.isEmpty) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func testDeletingATimezone() { |
|
|
|
func testDeletingATimezone() { |
|
|
|
let defaults = UserDefaults.standard |
|
|
|
let defaults = UserDefaults.standard |
|
|
|
|
|
|
|
|
|
|
@ -243,17 +254,61 @@ class ClockerUnitTests: XCTestCase { |
|
|
|
|
|
|
|
|
|
|
|
dataObject.setShouldOverrideGlobalTimeFormat(11) // 12-hour with preceding zero and seconds |
|
|
|
dataObject.setShouldOverrideGlobalTimeFormat(11) // 12-hour with preceding zero and seconds |
|
|
|
XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "hh:mm:ss") |
|
|
|
XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "hh:mm:ss") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dataObject.setShouldOverrideGlobalTimeFormat(12) // 12-hour with preceding zero and seconds |
|
|
|
|
|
|
|
XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "epoch") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func testSecondsDisplayForOverridenTimezone() { |
|
|
|
|
|
|
|
let dataObject = TimezoneData(with: california) |
|
|
|
|
|
|
|
UserDefaults.standard.set(NSNumber(value: 1), forKey: CLSelectedTimeZoneFormatKey) // Set to 24-Hour Format |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Test default behaviour |
|
|
|
|
|
|
|
let timezoneWithSecondsKeys = [4,5,8,11] |
|
|
|
|
|
|
|
for timezoneKey in timezoneWithSecondsKeys { |
|
|
|
|
|
|
|
dataObject.setShouldOverrideGlobalTimeFormat(timezoneKey) |
|
|
|
|
|
|
|
XCTAssertTrue(dataObject.shouldShowSeconds(DataStore.shared().timezoneFormat())) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let timezoneWithoutSecondsKeys = [1,2,7,10] |
|
|
|
|
|
|
|
for timezoneKey in timezoneWithoutSecondsKeys { |
|
|
|
|
|
|
|
dataObject.setShouldOverrideGlobalTimeFormat(timezoneKey) |
|
|
|
|
|
|
|
XCTAssertFalse(dataObject.shouldShowSeconds(DataStore.shared().timezoneFormat())) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Test wrong override timezone key |
|
|
|
|
|
|
|
let wrongTimezoneKey = 88 |
|
|
|
|
|
|
|
dataObject.setShouldOverrideGlobalTimeFormat(wrongTimezoneKey) |
|
|
|
|
|
|
|
XCTAssertFalse(dataObject.shouldShowSeconds(DataStore.shared().timezoneFormat())) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Test wrong global preference key |
|
|
|
|
|
|
|
dataObject.setShouldOverrideGlobalTimeFormat(0) |
|
|
|
|
|
|
|
XCTAssertFalse(dataObject.shouldShowSeconds(88)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func testTimezone() { |
|
|
|
|
|
|
|
let dataObject = TimezoneData(with: mumbai) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
XCTAssertEqual(dataObject.timezone(), "Asia/Calcutta") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dataObject.isSystemTimezone = true |
|
|
|
|
|
|
|
let autoupdatingTimezone = TimeZone.autoupdatingCurrent.identifier |
|
|
|
|
|
|
|
XCTAssertEqual(dataObject.timezone(), autoupdatingTimezone) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func testFormattedLabel() { |
|
|
|
func testFormattedLabel() { |
|
|
|
let dataObject = TimezoneData(with: mumbai) |
|
|
|
let dataObject = TimezoneData(with: mumbai) |
|
|
|
XCTAssertTrue(dataObject.formattedTimezoneLabel() == "Ghar", "Incorrect custom label returned by model.") |
|
|
|
XCTAssertTrue(dataObject.formattedTimezoneLabel() == "Ghar", "Incorrect custom label returned by model.") |
|
|
|
|
|
|
|
|
|
|
|
dataObject.customLabel = nil |
|
|
|
dataObject.setLabel("") |
|
|
|
XCTAssertTrue(dataObject.formattedTimezoneLabel() == "Mumbai", "Incorrect custom label returned by model.") |
|
|
|
XCTAssertTrue(dataObject.formattedTimezoneLabel() == "Mumbai", "Incorrect custom label returned by model.") |
|
|
|
|
|
|
|
|
|
|
|
dataObject.formattedAddress = nil |
|
|
|
dataObject.formattedAddress = nil |
|
|
|
XCTAssertTrue(dataObject.formattedTimezoneLabel() == "Asia", "Incorrect custom label returned by model.") |
|
|
|
XCTAssertTrue(dataObject.formattedTimezoneLabel() == "Asia", "Incorrect custom label returned by model.") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dataObject.setLabel("Jogeshwari") |
|
|
|
|
|
|
|
XCTAssertTrue(dataObject.formattedTimezoneLabel() == "Jogeshwari", "Incorrect custom label returned by model.") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func testEquality() { |
|
|
|
func testEquality() { |
|
|
|