Changeset cc3cf7d in Klonkt for test/object-links.test.js
- Timestamp:
- 07/26/2026 08:08:15 AM (6 weeks ago)
- Branches:
- main
- Children:
- 6fd0e20
- Parents:
- eb36688
- File:
-
- 1 edited
-
test/object-links.test.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
test/object-links.test.js
reb36688 rcc3cf7d 6 6 const dbMod = await import('../src/config/database.js'); 7 7 dbMod.initializeDatabase(); 8 const { extractObjectLinkTags, timelineObjectLinks } = await import('../src/services/ActivityPubService.js');9 const AP = { extractObjectLinkTags, timelineObjectLinks };8 const { extractObjectLinkTags, timelineObjectLinks, extractQuoteUrl, extractLinkJson } = await import('../src/services/ActivityPubService.js'); 9 const AP = { extractObjectLinkTags, timelineObjectLinks, extractQuoteUrl, extractLinkJson }; 10 10 11 11 test('extractObjectLinkTags keeps AS2-profiled ld+json and activity+json Links; drops plain links and mentions', () => { … … 31 31 assert.equal(AP.timelineObjectLinks('not json'), undefined); 32 32 }); 33 34 // FEP-044f: object-level quote properties are the common representation. 35 test('extractQuoteUrl reads quote / quoteUrl / quoteUri / _misskey_quote (string or embedded object)', () => { 36 assert.equal(AP.extractQuoteUrl({ quote: 'https://s/objects/9' }), 'https://s/objects/9'); 37 assert.equal(AP.extractQuoteUrl({ quoteUrl: 'https://s/q1' }), 'https://s/q1'); 38 assert.equal(AP.extractQuoteUrl({ quoteUri: 'https://s/q2' }), 'https://s/q2'); 39 assert.equal(AP.extractQuoteUrl({ _misskey_quote: 'https://s/q3' }), 'https://s/q3'); 40 assert.equal(AP.extractQuoteUrl({ quote: { type: 'Link', href: 'https://s/q4' } }), 'https://s/q4'); 41 assert.equal(AP.extractQuoteUrl({ content: 'no quote' }), null); 42 }); 43 44 test('extractLinkJson normalises an object-level quote into one FEP-e232 Link (rel _misskey_quote)', () => { 45 const json = AP.extractLinkJson({ content: 'nice', quoteUrl: 'https://s/objects/9' }); 46 const arr = AP.timelineObjectLinks(json); 47 assert.equal(arr.length, 1); 48 assert.equal(arr[0].href, 'https://s/objects/9'); 49 assert.ok(arr[0].rel.some((r) => r.includes('quote'))); 50 }); 51 52 test('extractLinkJson merges a real FEP-e232 Link with an object-level quote, deduped by href', () => { 53 const note = { 54 tag: [{ type: 'Link', mediaType: 'application/activity+json', href: 'https://s/objects/9' }], 55 quoteUrl: 'https://s/objects/9', // same target → not duplicated 56 }; 57 const arr = AP.timelineObjectLinks(AP.extractLinkJson(note)); 58 assert.equal(arr.length, 1); 59 assert.equal(arr[0].href, 'https://s/objects/9'); 60 });
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)