VexFlowMeasure_Test.ts 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* eslint-disable @typescript-eslint/no-unused-expressions */
  2. import {GraphicalMusicSheet} from "../../../../src/MusicalScore/Graphical/GraphicalMusicSheet";
  3. import {IXmlElement} from "../../../../src/Common/FileIO/Xml";
  4. import {MusicSheet} from "../../../../src/MusicalScore/MusicSheet";
  5. import {MusicSheetReader} from "../../../../src/MusicalScore/ScoreIO/MusicSheetReader";
  6. import {VexFlowMusicSheetCalculator} from "../../../../src/MusicalScore/Graphical/VexFlow/VexFlowMusicSheetCalculator";
  7. import {TestUtils} from "../../../Util/TestUtils";
  8. import {SourceMeasure} from "../../../../src/MusicalScore/VoiceData/SourceMeasure";
  9. import {SourceStaffEntry} from "../../../../src/MusicalScore/VoiceData/SourceStaffEntry";
  10. import {MusicSheetCalculator} from "../../../../src/MusicalScore/Graphical/MusicSheetCalculator";
  11. import {EngravingRules} from "../../../../src/MusicalScore/Graphical/EngravingRules";
  12. describe("VexFlow Measure", () => {
  13. it("Can create GraphicalMusicSheet", (done: Mocha.Done) => {
  14. const path: string = "MuzioClementi_SonatinaOpus36No1_Part1.xml";
  15. const score: Document = TestUtils.getScore(path);
  16. chai.expect(score).to.not.be.undefined;
  17. const partwise: Element = TestUtils.getPartWiseElement(score);
  18. chai.expect(partwise).to.not.be.undefined;
  19. const reader: MusicSheetReader = new MusicSheetReader();
  20. const calc: VexFlowMusicSheetCalculator = new VexFlowMusicSheetCalculator(reader.rules);
  21. const sheet: MusicSheet = reader.createMusicSheet(new IXmlElement(partwise), path);
  22. const gms: GraphicalMusicSheet = new GraphicalMusicSheet(sheet, calc);
  23. // console.log(gms);
  24. chai.expect(gms).to.not.be.undefined; // at least necessary for linter so that variable is not unused
  25. done();
  26. });
  27. it("Can have a single empty Measure", (done: Mocha.Done) => {
  28. const sheet: MusicSheet = new MusicSheet();
  29. sheet.Rules = new EngravingRules();
  30. const measure: SourceMeasure = new SourceMeasure(1, sheet.Rules);
  31. measure.FirstInstructionsStaffEntries[0] = new SourceStaffEntry(undefined, undefined);
  32. sheet.addMeasure(measure);
  33. const calc: MusicSheetCalculator = new VexFlowMusicSheetCalculator(sheet.Rules);
  34. const gms: GraphicalMusicSheet = new GraphicalMusicSheet(sheet, calc);
  35. chai.expect(gms.MeasureList.length).to.equal(1);
  36. chai.expect(gms.MeasureList[0].length).to.equal(1);
  37. chai.expect(gms.MeasureList[0][0].staffEntries.length).to.equal(0);
  38. done();
  39. });
  40. });