/** * This file is part of Satie music engraver . * Copyright (C) Joshua Netterfield 2015 - present. * * Satie is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * Satie is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with Satie. If not, see . */ /** * @file part of Satie test suite */ import ScoreHeader from "../engine_scoreHeader"; import {expect} from "chai"; import {parseScore, LeftCenterRight} from "musicxml-interfaces"; let headerTest = ` Song Title Song Composer Song Lyricist Song Arranger Song Copyright Song Software 1 Song Software 2 2015-03-10 title Song Title composer Song Composer rights Song Copyright Score rights Song Copyright MusicXML Part SmartMusic SoftSynth 1 1 15489 1 80 0 70 0 211 system 2 0 major G 2 8 1 light-heavy `; let minimalTest = ` MusicXML Part `; describe("[engine/scoreHeader.ts]", function() { // NOTE: Some of the tests in mxmljson_test indirectly test ScoreHeader! it("can correctly modify metadata", function() { let mxmljson = parseScore(headerTest); let scoreHeader = new ScoreHeader(mxmljson); expect(scoreHeader.credits.length).eq(5); expect(scoreHeader.identification.creators.length).eq(3); // Changing the composer should change the credit words and identification scoreHeader.composer = "New Composer"; expect(scoreHeader.credits.length).eq(5); expect(scoreHeader.identification.creators.length).eq(3); expect(scoreHeader.composer).to.eq("New Composer"); // Since get is not directly tied to set expect(scoreHeader.identification.creators[0].creator).to.eq("New Composer"); expect(scoreHeader.identification.creators[1].creator).to.not.eq("New Composer"); expect(scoreHeader.identification.creators[2].creator).to.not.eq("New Composer"); expect(scoreHeader.credits[1].creditWords[0].words).to.eq("New Composer"); // Changing the title should change credit words and movementTitle scoreHeader.title = "New Title"; expect(scoreHeader.credits.length).eq(5); expect(scoreHeader.identification.creators.length).eq(3); expect(scoreHeader.title).to.eq("New Title"); // Since get is not directly tied to set expect(scoreHeader.movementTitle).to.eq("New Title"); expect(scoreHeader.credits[0].creditWords[0].words).to.eq("New Title"); }); it("can correctly add metadata", function() { let mxmljson = parseScore(minimalTest); let scoreHeader = new ScoreHeader(mxmljson); expect(scoreHeader.credits.length).eq(0); expect(scoreHeader.identification.creators.length).eq(0); scoreHeader.title = "Orig Title"; scoreHeader.composer = "Orig Composer"; scoreHeader.arranger = "Orig Arranger"; scoreHeader.lyricist = "Orig Lyricist"; expect(scoreHeader.credits).to.deep.equal([ { creditImage: null, creditTypes: ["title"], creditWords: [{ words: "Orig Title", defaultX: 664.3076923076923, defaultY: 1657.8461538461538, fontSize: "18px", justify: LeftCenterRight.Center }], page: 1 }, { creditImage: null, creditTypes: ["composer"], creditWords: [{ words: "Orig Composer", defaultX: 1234.7692307692307, defaultY: 1596.3076923076922, fontSize: "12px", justify: LeftCenterRight.Right }], page: 1 }, { creditImage: null, creditTypes: ["arranger"], creditWords: [{ words: "Orig Arranger", defaultX: 1234.7692307692307, defaultY: 1503.9999999999998, fontSize: "12px", justify: LeftCenterRight.Right }], page: 1 }, { creditImage: null, creditTypes: ["lyricist"], creditWords: [{ words: "Orig Lyricist", defaultX: 1234.7692307692307, defaultY: 1411.6923076923076, fontSize: "12px", justify: LeftCenterRight.Right }], page: 1 } ]); }); });