Skip to content

Commit c0fdda0

Browse files
add test
1 parent 2f2580a commit c0fdda0

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/test/java/org/medicmobile/webapp/mobile/AppNotificationManagerTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,29 @@ public void showsOnlyMaxAllowedNotifications() throws JSONException {
7070
assertEquals(1, shadowNotificationManager.getAllNotifications().size());
7171
}
7272

73+
@Test
74+
public void respectsNotificationsOrderAndStoreLatestReadyAtTimestamp() throws JSONException {
75+
long latestReadyAtTimestamp = startOfDay + 1000 * 60;
76+
String jsData = getJSTaskNotificationString(startOfDay, startOfDay, startOfDay);
77+
String newNotificationData = """
78+
[
79+
%s,
80+
{
81+
"_id": "id_new",
82+
"readyAt": %d,
83+
"title": "Task for report 3",
84+
"contentText": "You have a Task 1",
85+
"endDate": %d,
86+
"dueDate": %d
87+
}
88+
]
89+
""".formatted(jsData, latestReadyAtTimestamp, startOfDay, startOfDay);
90+
appDataStore.saveLongBlocking(AppNotificationManager.MAX_NOTIFICATIONS_TO_SHOW_KEY, 1L);
91+
appNotificationManager.showNotificationsFromJsArray(newNotificationData);
92+
assertEquals(1, shadowNotificationManager.getAllNotifications().size());
93+
assertEquals(latestReadyAtTimestamp, appDataStore.getLongBlocking(AppNotificationManager.LATEST_NOTIFICATION_TIMESTAMP_KEY, 0L));
94+
}
95+
7396
@Test
7497
public void showsNotificationsOnNewDay() throws JSONException {
7598
long taskDate = startOfDay;

0 commit comments

Comments
 (0)