Export metadata edits (title, composer, source, encrypter) via patchScore
This commit is contained in:
@@ -403,6 +403,32 @@ ok('clean bar unchanged', barPatched.includes('beats_per_minute: 100'));
|
||||
ok('clean bar voice preserved', barPatched.includes('- D4 4'));
|
||||
ok('document separators preserved', (barPatched.match(/\n---\n/g) ?? []).length === 2);
|
||||
|
||||
// ── patchScore metadata ────────────────────────────────────────────────────
|
||||
section('patchScore metadata');
|
||||
const META_SCORE = `title: Old Title
|
||||
composer: Old Composer
|
||||
source: Some Book
|
||||
|
||||
instrument alpha:
|
||||
character:
|
||||
A: "1:0,10;1,0"
|
||||
`;
|
||||
const updatedInfo = { title: 'New Title', composer: 'New Composer', source: '', encrypter: 'Me' };
|
||||
const metaPatched = patchScore(META_SCORE, [], [], updatedInfo);
|
||||
ok('existing title replaced', metaPatched.includes('title: New Title'));
|
||||
ok('existing composer replaced', metaPatched.includes('composer: New Composer'));
|
||||
ok('empty value leaves existing line', metaPatched.includes('source: Some Book'));
|
||||
ok('new key prepended', metaPatched.includes('encrypter: Me'));
|
||||
ok('instrument block untouched', metaPatched.includes('instrument alpha:'));
|
||||
|
||||
const META_SCORE_NO_TITLE = `composer: Bach\n\ninstrument ki:\n character:\n`;
|
||||
const noTitlePatched = patchScore(META_SCORE_NO_TITLE, [], [], { title: 'Fugue', composer: 'Bach' });
|
||||
ok('missing title prepended', noTitlePatched.includes('title: Fugue'));
|
||||
ok('existing composer not duplicated', (noTitlePatched.match(/^composer:/mg) ?? []).length === 1);
|
||||
|
||||
const nullInfoPatched = patchScore(META_SCORE, [], [], null);
|
||||
ok('null info leaves metadata unchanged', nullInfoPatched.includes('title: Old Title'));
|
||||
|
||||
// ── Summary ────────────────────────────────────────────────────────────────
|
||||
console.log(`\n══ ${pass} passed, ${fail} failed ══\n`);
|
||||
process.exit(fail > 0 ? 1 : 0);
|
||||
|
||||
Reference in New Issue
Block a user