/* What a public Apple Music page says about itself, and which links this API is willing to fetch. * * The parser is best-effort by design — Apple's markup is theirs to change — so these tests are * about the two things that must not wobble: the schema block is read when it is there, the Open * Graph tags take over when it is not, and a page that is not a playlist at all returns nothing * rather than throwing. The allowlist gets the same treatment, because that one is a boundary * rather than a convenience. */ import { test } from 'node:test'; import assert from 'node:assert/strict'; import { parseMusicPage, hostAllowed } from '../music.js'; const PAGE = `
Leg Day`; test('reads the schema block first, and asks Apple\'s CDN for one useful size', () => { const m = parseMusicPage(PAGE); assert.equal(m.title, "Leg Day '24"); assert.equal(m.tracks, 42); assert.equal(m.curator, 'Ana'); assert.equal(m.artwork, 'https://is1-ssl.mzstatic.com/image/thumb/Feature/abc/600x600bb.jpg'); }); test('falls back to Open Graph, and never invents what it cannot read', () => { const noSchema = PAGE.replace(/