mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 20:26:24 +00:00
Show "unplayed" dot on incoming audio messages
This commit is contained in:
55
ts/test-both/messages/migrateLegacyReadStatus_test.ts
Normal file
55
ts/test-both/messages/migrateLegacyReadStatus_test.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
// We want to cast to `any` because we're passing an unexpected field.
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
|
||||
import { assert } from 'chai';
|
||||
import { ReadStatus } from '../../messages/MessageReadStatus';
|
||||
|
||||
import { migrateLegacyReadStatus } from '../../messages/migrateLegacyReadStatus';
|
||||
|
||||
describe('migrateLegacyReadStatus', () => {
|
||||
it("doesn't migrate messages that already have the modern read state", () => {
|
||||
assert.isUndefined(
|
||||
migrateLegacyReadStatus({ readStatus: ReadStatus.Read })
|
||||
);
|
||||
assert.isUndefined(
|
||||
migrateLegacyReadStatus({ readStatus: ReadStatus.Unread })
|
||||
);
|
||||
});
|
||||
|
||||
it('converts legacy read values to "read"', () => {
|
||||
assert.strictEqual(migrateLegacyReadStatus({}), ReadStatus.Read);
|
||||
assert.strictEqual(
|
||||
migrateLegacyReadStatus({ unread: 0 } as any),
|
||||
ReadStatus.Read
|
||||
);
|
||||
assert.strictEqual(
|
||||
migrateLegacyReadStatus({ unread: false } as any),
|
||||
ReadStatus.Read
|
||||
);
|
||||
});
|
||||
|
||||
it('converts legacy unread values to "unread"', () => {
|
||||
assert.strictEqual(
|
||||
migrateLegacyReadStatus({ unread: 1 } as any),
|
||||
ReadStatus.Unread
|
||||
);
|
||||
assert.strictEqual(
|
||||
migrateLegacyReadStatus({ unread: true } as any),
|
||||
ReadStatus.Unread
|
||||
);
|
||||
});
|
||||
|
||||
it('converts unexpected truthy values to "unread"', () => {
|
||||
assert.strictEqual(
|
||||
migrateLegacyReadStatus({ unread: 99 } as any),
|
||||
ReadStatus.Unread
|
||||
);
|
||||
assert.strictEqual(
|
||||
migrateLegacyReadStatus({ unread: 'wow!' } as any),
|
||||
ReadStatus.Unread
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user