Files
im_webapp/web/tests/chat-list.test.ts
T

25 lines
849 B
TypeScript

import assert from 'node:assert/strict';
import test from 'node:test';
import { friendAvatarLookup } from '../src/features/messages/chat-list.ts';
test('friend avatars resolve by both user ID and established P2P topic', () => {
const avatars = friendAvatarLookup([
{
user_id: 'usr-potter',
topic: 'p2p-potter',
avatar_file_id: 'https://example.com/potter.png',
},
]);
assert.equal(avatars.get('usr-potter'), 'https://example.com/potter.png');
assert.equal(avatars.get('p2p-potter'), 'https://example.com/potter.png');
});
test('friend avatar lookup tolerates a new conversation without a topic alias', () => {
const avatars = friendAvatarLookup([{ user_id: 'usr-new', avatar_file_id: 'avatar-file-id' }]);
assert.equal(avatars.get('usr-new'), 'avatar-file-id');
assert.equal(avatars.has(''), false);
});