Mxl.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. "use strict";
  2. var Mxl_ts_1 = require("../../../src/Common/FileIO/Mxl.ts");
  3. var TestUtils_1 = require("../../Util/TestUtils");
  4. describe("MXL Tests", function () {
  5. // Generates a test for a mxl file name
  6. function testFile(scoreName) {
  7. it(scoreName, function (done) {
  8. // Load the xml file content
  9. var mxl = TestUtils_1.TestUtils.getMXL(scoreName);
  10. chai.expect(mxl).to.not.be.undefined;
  11. // Extract XML from MXL
  12. // Warning: the sheet is loaded asynchronously,
  13. // (with Promises), thus we need a little fix
  14. // in the end with 'then(null, done)' to
  15. // make Mocha work asynchronously
  16. Mxl_ts_1.MXLtoIXmlElement(mxl).then(function (score) {
  17. chai.expect(score).to.not.be.undefined;
  18. chai.expect(score.name).to.equal("score-partwise");
  19. done();
  20. }, function (exc) { throw exc; }).then(undefined, done);
  21. });
  22. }
  23. // Test all the following mxl files:
  24. var scores = ["MozartTrio"];
  25. for (var _i = 0, scores_1 = scores; _i < scores_1.length; _i++) {
  26. var score = scores_1[_i];
  27. testFile(score);
  28. }
  29. // Test failure
  30. it("Corrupted file", function (done) {
  31. Mxl_ts_1.MXLtoIXmlElement("").then(function (score) {
  32. chai.expect(score).to.not.be.undefined;
  33. chai.expect(score.name).to.equal("score-partwise");
  34. done(new Error("Empty zip file was loaded correctly. How is that even possible?"));
  35. }, function (exc) { done(); });
  36. });
  37. });