Skip to content

Commit

Permalink
actually fix nudge tests
Browse files Browse the repository at this point in the history
  • Loading branch information
erikng committed Jan 9, 2024
1 parent 79a2846 commit b001a75
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Nudge/Utilities/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ struct ConfigurationManager {
}

struct DateManager {
private let dateFormatterISO8601: DateFormatter = {
let dateFormatterISO8601: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'"
formatter.locale = Locale(identifier: "en_US_POSIX")
Expand Down
7 changes: 2 additions & 5 deletions NudgeTests/NudgeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ var defaultPreferencesForTests = [:] as [String : Any]

class NudgeTests: XCTestCase {
func coerceStringToDate(dateString: String) -> Date {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'"
let formattedDate = dateFormatter.date(from: dateString) ?? DateManager().getCurrentDate()
return formattedDate
DateManager().dateFormatterISO8601.date(from: dateString) ?? DateManager().getCurrentDate()
}

override func setUp() {
Expand Down Expand Up @@ -89,7 +86,7 @@ class NudgeTests: XCTestCase {
defaultPreferencesForTests["requiredMinimumOSVersion"] = "99.99.99"
PrefsWrapper.prefsOverride = defaultPreferencesForTests
XCTAssertEqual(
coerceStringToDate(dateString: "2022-01-03T00:00:00Z"),
coerceStringToDate(dateString: "2022-01-02T00:30:00Z"),
AppStateManager().gracePeriodLogic(
currentDate: coerceStringToDate(dateString: "2022-01-02T00:30:00Z"),
testFileDate: coerceStringToDate(dateString: "2022-01-02T00:00:00Z")
Expand Down

0 comments on commit b001a75

Please sign in to comment.