Changeset e9ec5e4 in Klonkt for test/following-csv.test.js
- Timestamp:
- 08/13/2026 06:16:49 PM (4 weeks ago)
- Branches:
- main
- Children:
- fbda20e
- Parents:
- 096f099
- File:
-
- 1 edited
-
test/following-csv.test.js (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
test/following-csv.test.js
r096f099 re9ec5e4 24 24 const { importFollowing } = await import('../src/services/ArchiveImportService.js'); 25 25 26 const volg = db.prepare(`INSERT INTO ap_following (slug, actor_uri, handle, status, auto_boost , highlighted)27 VALUES (?,?,?,?,? ,?)`);26 const volg = db.prepare(`INSERT INTO ap_following (slug, actor_uri, handle, status, auto_boost) 27 VALUES (?,?,?,?,?)`); 28 28 29 29 beforeEach(() => { … … 32 32 33 33 test('de CSV heeft de Mastodon-koppen, met Featured erachter', () => { 34 volg.run('me', 'https://a.example/ap/users/jason', '@jason@a.example', 'accepted', 1 , 1);34 volg.run('me', 'https://a.example/ap/users/jason', '@jason@a.example', 'accepted', 1); 35 35 const csv = followingCsv('me'); 36 36 const [kop, eerste] = csv.trim().split('\n'); 37 37 assert.equal(kop, 'Account address,Show boosts,Notify on new posts,Languages,Featured'); 38 38 // Zonder de leidende @, want zo schrijft Mastodon het adres. 39 assert.equal(eerste, 'jason@a.example, true,false,,true');39 assert.equal(eerste, 'jason@a.example,,,,true'); 40 40 }); 41 41 42 42 test('een openstaand verzoek gaat NIET mee', () => { 43 volg.run('me', 'https://a.example/ap/users/wacht', '@wacht@a.example', 'pending', 0 , 0);44 volg.run('me', 'https://a.example/ap/users/ja', '@ja@a.example', 'accepted', 0 , 0);43 volg.run('me', 'https://a.example/ap/users/wacht', '@wacht@a.example', 'pending', 0); 44 volg.run('me', 'https://a.example/ap/users/ja', '@ja@a.example', 'accepted', 0); 45 45 const regels = followingCsv('me').trim().split('\n').slice(1); 46 46 assert.equal(regels.length, 1, 'een verzoek dat iemand bewust liet liggen mag niet opnieuw verstuurd worden'); … … 49 49 50 50 test('zonder handle valt hij terug op de actor-URI', () => { 51 volg.run('me', 'https://a.example/ap/users/naamloos', null, 'accepted', 0 , 0);51 volg.run('me', 'https://a.example/ap/users/naamloos', null, 'accepted', 0); 52 52 assert.match(followingCsv('me'), /https:\/\/a\.example\/ap\/users\/naamloos/); 53 53 }); … … 58 58 59 59 test('een export leest zichzelf terug', () => { 60 volg.run('me', 'https://a.example/ap/users/a', '@a@a.example', 'accepted', 1 , 0);61 volg.run('me', 'https://b.example/ap/users/b', '@b@b.example', 'accepted', 0 , 1);60 volg.run('me', 'https://a.example/ap/users/a', '@a@a.example', 'accepted', 1); 61 volg.run('me', 'https://b.example/ap/users/b', '@b@b.example', 'accepted', 0); 62 62 const terug = parseFollowingCsv(followingCsv('me')); 63 63 assert.deepEqual(terug, [ 64 { address: 'a@a.example', autoBoost: true, highlighted: false },65 { address: 'b@b.example', autoBoost: false, highlighted: true },64 { address: 'a@a.example', featured: true }, 65 { address: 'b@b.example', featured: false }, 66 66 ]); 67 67 }); … … 72 72 + 'iemand@mastodon.social,true,false,\n', 73 73 ); 74 assert.deepEqual(uit, [{ address: 'iemand@mastodon.social', autoBoost: true, highlighted: false }]); 74 // Hun "Show boosts" staat op true, en dat mag hier NIET als uitgelicht landen. 75 assert.deepEqual(uit, [{ address: 'iemand@mastodon.social', featured: false }]); 75 76 }); 76 77 … … 83 84 const uit = parseFollowingCsv('Account address,Show boosts\n"raar,naam@a.example",true\n'); 84 85 assert.equal(uit[0].address, 'raar,naam@a.example'); 85 assert.equal(uit[0].autoBoost, true);86 86 }); 87 87 … … 90 90 const r = await importFollowing({ slug: 'me' }, 91 91 'Account address,Show boosts,Notify on new posts,Languages,Featured\n' 92 + 'a@a.example, true,false,,false\n'93 + 'b@b.example, false,false,,true\n',92 + 'a@a.example,,,,true\n' 93 + 'b@b.example,,,,false\n', 94 94 { followFn: async (site, adres, boost) => { gezien.push([adres, boost]); return true; } }); 95 95 96 assert.deepEqual(gezien, [['a@a.example', true], ['b@b.example', false]]); 96 assert.deepEqual(gezien, [['a@a.example', true], ['b@b.example', false]], 97 'de uitgelicht-stand moet als derde argument mee de Follow in'); 97 98 assert.equal(r.gevolgd, 2); 98 99 assert.equal(r.mislukt.length, 0); … … 130 131 db.prepare('INSERT OR IGNORE INTO sites (id, slug, title, owner_id) VALUES (?,?,?,?)') 131 132 .run('s1', 'me', 'Mijn site', 'u1'); 132 volg.run('me', 'https://a.example/ap/users/jason', '@jason@a.example', 'accepted', 1 , 1);133 volg.run('me', 'https://a.example/ap/users/jason', '@jason@a.example', 'accepted', 1); 133 134 134 135 const { buildArchive } = await import('../src/services/ArchiveExportService.js'); … … 138 139 assert.equal(r.counts.following, 1); 139 140 assert.ok(r.manifest.files['following.csv'], 'en hij hoort in het manifest, anders telt hij niet mee bij de controle'); 140 assert.match(String(r.files.get('following.csv')), /jason@a\.example, true,false,,true/);141 assert.match(String(r.files.get('following.csv')), /jason@a\.example,,,,true/); 141 142 });
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)