Skip to content

Commit c021ef3

Browse files
committed
fix: take reads into account in tests as well
1 parent b44dcc2 commit c021ef3

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

package/src/__tests__/offline-support/offline-feature.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,14 @@ export const Generic = () => {
565565
const messagesRows = await BetterSqlite.selectFromTable('messages');
566566
const matchingMessagesRows = messagesRows.filter((m) => m.cid === channelToTruncate.cid);
567567

568+
const readsRows = await BetterSqlite.selectFromTable('reads');
569+
const matchingReadRows = readsRows.filter(
570+
(r) => r.userId === chatClient.userID && r.cid === channelToTruncate.cid,
571+
);
572+
568573
expect(matchingMessagesRows.length).toBe(0);
574+
expect(matchingReadRows.length).toBe(1);
575+
expect(matchingReadRows[0].unreadMessages).toBe(0);
569576
});
570577
});
571578

@@ -600,7 +607,16 @@ export const Generic = () => {
600607
const messagesRows = await BetterSqlite.selectFromTable('messages');
601608
const matchingMessagesRows = messagesRows.filter((m) => m.cid === channelToTruncate.cid);
602609

603-
expect(matchingMessagesRows.length).toBe(messages.length / 2 - 1);
610+
const readsRows = await BetterSqlite.selectFromTable('reads');
611+
const matchingReadRows = readsRows.filter(
612+
(r) => r.userId === chatClient.userID && r.cid === channelToTruncate.cid,
613+
);
614+
615+
const messagesLeft = messages.length / 2 - 1;
616+
617+
expect(matchingMessagesRows.length).toBe(messagesLeft);
618+
expect(matchingReadRows.length).toBe(1);
619+
expect(matchingReadRows[0].unreadMessages).toBe(messagesLeft);
604620
});
605621
});
606622

0 commit comments

Comments
 (0)