import test from 'brittle'
import { extractMediaHashes } from '../../lib/multiwriter/notebook-apply.js'
test('extractMediaHashes - finds image hashes in markdown', async (t) => {
const content = 'Some text  and more '
const hashes = extractMediaHashes(content)
t.is(hashes.size, 2)
t.ok(hashes.has('abc123def456'))
t.ok(hashes.has('789012fed345'))
})
test('extractMediaHashes - returns empty set for no media', async (t) => {
const content = 'Just text, no images'
const hashes = extractMediaHashes(content)
t.is(hashes.size, 0)
})
test('extractMediaHashes - returns empty set for null/undefined', async (t) => {
t.is(extractMediaHashes(null).size, 0)
t.is(extractMediaHashes(undefined).size, 0)
t.is(extractMediaHashes('').size, 0)
})
test('extractMediaHashes - handles 64-char hex hash references', async (t) => {
const hash = 'a'.repeat(64)
const content = ''
const hashes = extractMediaHashes(content)
t.is(hashes.size, 1)
t.ok(hashes.has(hash))
})
test('extractMediaHashes - handles mixed old and new style refs', async (t) => {
const hash = 'b'.repeat(64)
const content = '\n'
const hashes = extractMediaHashes(content)
t.is(hashes.size, 2)
t.ok(hashes.has('lq3x2abc.jpg'))
t.ok(hashes.has(hash))
})