TestUtils.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. "use strict";
  2. /**
  3. * This class collects useful methods to interact with test data.
  4. * During tests, XML and MXL documents are preprocessed by karma,
  5. * and this is some helper code to retrieve them.
  6. */
  7. var TestUtils = (function () {
  8. function TestUtils() {
  9. }
  10. TestUtils.getScore = function (name) {
  11. var path = "test/data/" + name + ".xml";
  12. return (window.__xml__)[path];
  13. };
  14. TestUtils.getMXL = function (scoreName) {
  15. var path = "test/data/" + scoreName + ".mxl";
  16. return (window.__raw__)[path];
  17. };
  18. /**
  19. * Retrieve from a XML document the first element with name "score-partwise"
  20. * @param doc is the XML Document
  21. * @returns {Element}
  22. */
  23. TestUtils.getPartWiseElement = function (doc) {
  24. var nodes = doc.childNodes;
  25. for (var i = 0, length_1 = nodes.length; i < length_1; i += 1) {
  26. var node = nodes[i];
  27. if (node.nodeType === Node.ELEMENT_NODE && node.nodeName.toLowerCase() === "score-partwise") {
  28. return node;
  29. }
  30. }
  31. };
  32. return TestUtils;
  33. }());
  34. exports.TestUtils = TestUtils;