Browse Source

Handle one hour changes.

pull/113/head
Abhishek Banthia 2 years ago
parent
commit
48b5577d9f
  1. 28
      Clocker/ClockerUnitTests/EventInfoTests.swift
  2. 2
      Clocker/Dependencies/Date Additions/Date+TimeAgo.swift

28
Clocker/ClockerUnitTests/EventInfoTests.swift

@ -76,4 +76,32 @@ class EventInfoTests: XCTestCase {
XCTAssert(mockEventInfo.metadataForMeeting() == "in 25h",
"Metadata for meeting: \(mockEventInfo.metadataForMeeting()) doesn't match expectation")
}
func testMetadataForEventHappeningAfterAnHour() throws {
let pastChunk = TimeChunk(seconds: 10, minutes: 10, hours: 1, days: 0, weeks: 0, months: 0, years: 0)
let mockEvent = EKEvent(eventStore: eventStore)
mockEvent.title = "Mock Title"
mockEvent.startDate = Date().add(pastChunk)
let mockEventInfo = EventInfo(event: mockEvent,
isAllDay: false,
meetingURL: nil,
attendeStatus: .accepted)
XCTAssert(mockEventInfo.metadataForMeeting() == "in 1h",
"Metadata for meeting: \(mockEventInfo.metadataForMeeting()) doesn't match expectation")
}
func testMetadataForEventHappeningAfterThreeHours() throws {
let pastChunk = TimeChunk(seconds: 10, minutes: 10, hours: 3, days: 0, weeks: 0, months: 0, years: 0)
let mockEvent = EKEvent(eventStore: eventStore)
mockEvent.title = "Mock Title"
mockEvent.startDate = Date().add(pastChunk)
let mockEventInfo = EventInfo(event: mockEvent,
isAllDay: false,
meetingURL: nil,
attendeStatus: .accepted)
XCTAssert(mockEventInfo.metadataForMeeting() == "in 3h",
"Metadata for meeting: \(mockEventInfo.metadataForMeeting()) doesn't match expectation")
}
}

2
Clocker/Dependencies/Date Additions/Date+TimeAgo.swift

@ -113,7 +113,7 @@ public extension Date {
return DateToolsLocalizedStrings("1 hour ago")
}
return DateToolsLocalizedStrings("An hour ago")
return DateToolsLocalizedStrings("1h ago")
} else if components.minute! >= 2 {
return logicalLocalizedStringFromFormat(format: "%%d%@m ago", value: components.minute!)
} else if components.minute! >= 1 {

Loading…
Cancel
Save