getUnreadByConversationAndMarkRead: Take 'now' param for reliable tests

This commit is contained in:
Scott Nonnenberg 2022-09-22 16:49:06 -07:00 committed by GitHub
parent 77bf3a8669
commit a7253be213
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 3 deletions

View file

@ -304,6 +304,7 @@ describe('sql/markRead', () => {
});
it('properly starts disappearing message timer, even if message is already read', async () => {
const now = Date.now();
assert.lengthOf(await _getAllMessages(), 0);
const start = Date.now();
@ -387,6 +388,7 @@ describe('sql/markRead', () => {
conversationId,
newestUnreadAt: message4.received_at,
readAt,
now,
});
assert.lengthOf(markedRead, 1, 'one message marked read');
@ -412,14 +414,14 @@ describe('sql/markRead', () => {
assert.strictEqual(sorted[1].id, message2.id, 'checking message 2');
assert.isAtMost(
sorted[1].expirationStartTimestamp ?? Infinity,
Date.now(),
now,
'checking message 2 expirationStartTimestamp'
);
assert.strictEqual(sorted[3].id, message4.id, 'checking message 4');
assert.isAtMost(
sorted[3].expirationStartTimestamp ?? Infinity,
Date.now(),
now,
'checking message 4 expirationStartTimestamp'
);
});