| … | … | @@ -0,0 +1,39 @@ |
| 1 | import test from 'brittle' |
| 2 | import { extractMediaHashes } from '../../lib/multiwriter/notebook-apply.js' |
| 3 | |
| 4 | test('extractMediaHashes - finds image hashes in markdown', async (t) => { |
| 5 | const content = 'Some text  and more ' |
| 6 | const hashes = extractMediaHashes(content) |
| 7 | t.is(hashes.size, 2) |
| 8 | t.ok(hashes.has('abc123def456')) |
| 9 | t.ok(hashes.has('789012fed345')) |
| 10 | }) |
| 11 | |
| 12 | test('extractMediaHashes - returns empty set for no media', async (t) => { |
| 13 | const content = 'Just text, no images' |
| 14 | const hashes = extractMediaHashes(content) |
| 15 | t.is(hashes.size, 0) |
| 16 | }) |
| 17 | |
| 18 | test('extractMediaHashes - returns empty set for null/undefined', async (t) => { |
| 19 | t.is(extractMediaHashes(null).size, 0) |
| 20 | t.is(extractMediaHashes(undefined).size, 0) |
| 21 | t.is(extractMediaHashes('').size, 0) |
| 22 | }) |
| 23 | |
| 24 | test('extractMediaHashes - handles 64-char hex hash references', async (t) => { |
| 25 | const hash = 'a'.repeat(64) |
| 26 | const content = '' |
| 27 | const hashes = extractMediaHashes(content) |
| 28 | t.is(hashes.size, 1) |
| 29 | t.ok(hashes.has(hash)) |
| 30 | }) |
| 31 | |
| 32 | test('extractMediaHashes - handles mixed old and new style refs', async (t) => { |
| 33 | const hash = 'b'.repeat(64) |
| 34 | const content = '\n' |
| 35 | const hashes = extractMediaHashes(content) |
| 36 | t.is(hashes.size, 2) |
| 37 | t.ok(hashes.has('lq3x2abc.jpg')) |
| 38 | t.ok(hashes.has(hash)) |
| 39 | }) |