2021-07-29 14:29:07 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import { assert } from 'chai';
|
2021-08-12 18:15:55 +00:00
|
|
|
import { ReadStatus } from '../../messages/MessageReadStatus';
|
2021-07-29 14:29:07 +00:00
|
|
|
|
|
|
|
import { isMessageUnread } from '../../util/isMessageUnread';
|
|
|
|
|
|
|
|
describe('isMessageUnread', () => {
|
2021-08-12 18:15:55 +00:00
|
|
|
it("returns false if the message's `readStatus` field is undefined", () => {
|
2021-07-29 14:29:07 +00:00
|
|
|
assert.isFalse(isMessageUnread({}));
|
2021-08-12 18:15:55 +00:00
|
|
|
assert.isFalse(isMessageUnread({ readStatus: undefined }));
|
2021-07-29 14:29:07 +00:00
|
|
|
});
|
|
|
|
|
2021-08-12 18:15:55 +00:00
|
|
|
it('returns false if the message is read or viewed', () => {
|
|
|
|
assert.isFalse(isMessageUnread({ readStatus: ReadStatus.Read }));
|
|
|
|
assert.isFalse(isMessageUnread({ readStatus: ReadStatus.Viewed }));
|
2021-07-29 14:29:07 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('returns true if the message is unread', () => {
|
2021-08-12 18:15:55 +00:00
|
|
|
assert.isTrue(isMessageUnread({ readStatus: ReadStatus.Unread }));
|
2021-07-29 14:29:07 +00:00
|
|
|
});
|
|
|
|
});
|