diff --git a/js/__tests__/mxml.test.js b/js/__tests__/mxml.test.js new file mode 100644 index 0000000000..523d27e71a --- /dev/null +++ b/js/__tests__/mxml.test.js @@ -0,0 +1,151 @@ +const saveMxmlOutput = require("../mxml"); + +describe("saveMxmlOutput", () => { + it("should return a valid XML string for a basic input", () => { + const logo = { + notation: { + notationStaging: { + "0": [ + [["C"], 4, 0], + ], + "1": [] + } + } + }; + + const output = saveMxmlOutput(logo); + + expect(output).toContain(""); + expect(output).toContain(""); + expect(output).toContain(""); + expect(output).toContain(""); + expect(output).toContain(""); + }); + + it("should handle multiple voices", () => { + const logo = { + notation: { + notationStaging: { + "0": [ + [["C"], 4, 0], + [["D"], 4, 0] + ], + "1": [ + [["E"], 4, 0], + [["F"], 4, 0] + ] + } + } + }; + + const output = saveMxmlOutput(logo); + + expect(output).toContain(""); + expect(output).toContain(""); + expect(output).toContain(""); + expect(output).toContain(""); + expect(output).toContain("C"); + expect(output).toContain("E"); + }); + + it("should ignore specified elements", () => { + const logo = { + notation: { + notationStaging: { + "0": [ + "voice one", + [["C"], 4, 0], + "voice two" + ] + } + } + }; + + const output = saveMxmlOutput(logo); + + expect(output).not.toContain("voice one"); + expect(output).not.toContain("voice two"); + expect(output).toContain("C"); + }); + + it("should handle tempo changes", () => { + const logo = { + notation: { + notationStaging: { + "0": [ + "tempo", 120, 4, + [["C"], 4, 0] + ] + } + } + }; + + const output = saveMxmlOutput(logo); + + expect(output).toContain(""); + expect(output).toContain("C"); + }); + + it("should handle meter changes", () => { + const logo = { + notation: { + notationStaging: { + "0": [ + "meter", 3, 4, + [["C"], 4, 0] + ] + } + } + }; + + const output = saveMxmlOutput(logo); + + expect(output).toContain("