Mxl.js 1.6 KB

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