diff --git a/Calendr.xcodeproj/project.pbxproj b/Calendr.xcodeproj/project.pbxproj index bf77aed..ad22a81 100644 --- a/Calendr.xcodeproj/project.pbxproj +++ b/Calendr.xcodeproj/project.pbxproj @@ -1507,7 +1507,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); - MARKETING_VERSION = 1.15.0; + MARKETING_VERSION = 1.15.1; PRODUCT_BUNDLE_IDENTIFIER = br.paker.Calendr; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Calendr/Config/Calendr-Bridging-Header.h"; @@ -1535,7 +1535,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); - MARKETING_VERSION = 1.15.0; + MARKETING_VERSION = 1.15.1; PRODUCT_BUNDLE_IDENTIFIER = br.paker.Calendr; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Calendr/Config/Calendr-Bridging-Header.h"; diff --git a/Calendr/Events/EventList/EventViewModel.swift b/Calendr/Events/EventList/EventViewModel.swift index 8b3faf8..b5ba28d 100644 --- a/Calendr/Events/EventList/EventViewModel.swift +++ b/Calendr/Events/EventList/EventViewModel.swift @@ -224,7 +224,7 @@ class EventViewModel { clock = .just(()) } - if event.type == .reminder(completed: false) { + if event.type == .reminder(completed: false), !event.isAllDay { let dateFormatter = DateComponentsFormatter() dateFormatter.calendar = dateProvider.calendar diff --git a/CalendrTests/EventViewModelTests.swift b/CalendrTests/EventViewModelTests.swift index ead0595..2809145 100644 --- a/CalendrTests/EventViewModelTests.swift +++ b/CalendrTests/EventViewModelTests.swift @@ -321,6 +321,64 @@ class EventViewModelTests: XCTestCase { XCTAssertEqual(mock(type: .event(.maybe)).barStyle, .bordered) } + func testReminderDuration() { + + let viewModel = mock( + event: .make( + start: .make(year: 2021, month: 1, day: 1, hour: 1), + type: .reminder(completed: false) + ) + ) + + XCTAssertEqual(viewModel.duration.lastValue(), "1:00 AM") + } + + func testOverdueReminder_shouldShowRelativeDuration() { + + dateProvider.now = .make(year: 2021, month: 1, day: 1, hour: 0, minute: 30) + + let viewModel = mock( + event: .make( + start: .make(year: 2021, month: 1, day: 1, hour: 0, minute: 15), + type: .reminder(completed: false) + ) + ) + + XCTAssertEqual(viewModel.duration.lastValue(), "12:15 AM") + XCTAssertEqual(viewModel.relativeDuration.lastValue(), "15m ago") + } + + func testOverdueReminder_isCompleted_shouldNotShowRelativeDuration() { + + dateProvider.now = .make(year: 2021, month: 1, day: 1, hour: 0, minute: 30) + + let viewModel = mock( + event: .make( + start: .make(year: 2021, month: 1, day: 1, hour: 0, minute: 15), + type: .reminder(completed: true) + ) + ) + + XCTAssertEqual(viewModel.duration.lastValue(), "12:15 AM") + XCTAssertNil(viewModel.relativeDuration.lastValue()) + } + + func testOverdueReminder_isAllDay_shouldNotShowDurationOrRelativeDuration() { + + dateProvider.now = .make(year: 2021, month: 1, day: 1, hour: 0, minute: 30) + + let viewModel = mock( + event: .make( + start: .make(year: 2021, month: 1, day: 1), + isAllDay: true, + type: .reminder(completed: false) + ) + ) + + XCTAssertEqual(viewModel.duration.lastValue(), "") + XCTAssertNil(viewModel.relativeDuration.lastValue()) + } + func testReminder_toggleComplete_isNotCompleted() { let viewModel = mock(type: .reminder(completed: false))