Skip to content

Commit

Permalink
Hide relative duration for all day reminders (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
pakerwreah authored Dec 27, 2024
1 parent 072d736 commit f9c6708
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Calendr.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion Calendr/Events/EventList/EventViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
58 changes: 58 additions & 0 deletions CalendrTests/EventViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit f9c6708

Please sign in to comment.