| [97bacf2] | 1 | // FEP-9098: Klonkt keeps inbound custom-emoji tags and serves them on the C2S inbox read.
|
|---|
| 2 | import { test } from 'node:test';
|
|---|
| 3 | import assert from 'node:assert/strict';
|
|---|
| 4 | process.env.DATABASE_PATH = ':memory:';
|
|---|
| 5 | process.env.PUBLIC_BASE_URL = 'https://test.example';
|
|---|
| 6 | const dbMod = await import('../src/config/database.js');
|
|---|
| 7 | dbMod.initializeDatabase();
|
|---|
| 8 | const { extractEmojiTags, timelineEmojis } = await import('../src/services/ActivityPubService.js');
|
|---|
| 9 | const AP = { extractEmojiTags, timelineEmojis };
|
|---|
| 10 |
|
|---|
| 11 | test('extractEmojiTags keeps only Emoji tags; timelineEmojis round-trips', () => {
|
|---|
| 12 | const tag = [
|
|---|
| 13 | { type: 'Mention', href: 'https://s/u/x' },
|
|---|
| 14 | { type: 'Emoji', name: ':wave:', icon: { type: 'Image', url: 'https://s/wave.png' } },
|
|---|
| 15 | { type: 'Hashtag', name: '#hi' },
|
|---|
| 16 | ];
|
|---|
| 17 | const json = AP.extractEmojiTags(tag);
|
|---|
| 18 | assert.ok(json);
|
|---|
| 19 | const back = AP.timelineEmojis(json);
|
|---|
| 20 | assert.equal(back.length, 1);
|
|---|
| 21 | assert.equal(back[0].name, ':wave:');
|
|---|
| 22 | assert.equal(back[0].icon.url, 'https://s/wave.png');
|
|---|
| 23 | });
|
|---|
| 24 |
|
|---|
| 25 | test('no emojis → null / undefined (nothing served)', () => {
|
|---|
| 26 | assert.equal(AP.extractEmojiTags([{ type: 'Mention' }]), null);
|
|---|
| 27 | assert.equal(AP.timelineEmojis(null), undefined);
|
|---|
| 28 | assert.equal(AP.timelineEmojis('not json'), undefined);
|
|---|
| 29 | });
|
|---|