suite-numbering-processor.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = function (d, b) {
  4. extendStatics = Object.setPrototypeOf ||
  5. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. };
  9. return function (d, b) {
  10. if (typeof b !== "function" && b !== null)
  11. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  12. extendStatics(d, b);
  13. function __() { this.constructor = d; }
  14. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15. };
  16. })();
  17. Object.defineProperty(exports, "__esModule", { value: true });
  18. exports.SuiteNumberingProcessor = void 0;
  19. var display_processor_1 = require("../display-processor");
  20. var SuiteNumberingProcessor = /** @class */ (function (_super) {
  21. __extends(SuiteNumberingProcessor, _super);
  22. function SuiteNumberingProcessor() {
  23. var _this = _super !== null && _super.apply(this, arguments) || this;
  24. _this.suiteHierarchy = [];
  25. return _this;
  26. }
  27. SuiteNumberingProcessor.getParentName = function (element) {
  28. return element.fullName.replace(element.description, "").trim();
  29. };
  30. SuiteNumberingProcessor.prototype.displaySuite = function (suite, log) {
  31. return this.computeNumber(suite) + " " + log;
  32. };
  33. SuiteNumberingProcessor.prototype.computeNumber = function (suite) {
  34. this.computeHierarchy(suite);
  35. return this.computeHierarchyNumber();
  36. };
  37. SuiteNumberingProcessor.prototype.computeHierarchy = function (suite) {
  38. var parentName = SuiteNumberingProcessor.getParentName(suite);
  39. var i = 0;
  40. for (; i < this.suiteHierarchy.length; i++) {
  41. if (this.suiteHierarchy[i].name === parentName) {
  42. this.suiteHierarchy[i].number++;
  43. this.suiteHierarchy.splice(i + 1, this.suiteHierarchy.length - i - 1);
  44. break;
  45. }
  46. }
  47. if (i === this.suiteHierarchy.length) {
  48. this.suiteHierarchy.push({ name: parentName, number: 1 });
  49. }
  50. };
  51. SuiteNumberingProcessor.prototype.computeHierarchyNumber = function () {
  52. var hierarchyNumber = "";
  53. for (var _i = 0, _a = this.suiteHierarchy; _i < _a.length; _i++) {
  54. var suite = _a[_i];
  55. hierarchyNumber += suite.number + ".";
  56. }
  57. return hierarchyNumber.substring(0, hierarchyNumber.length - 1);
  58. };
  59. return SuiteNumberingProcessor;
  60. }(display_processor_1.DisplayProcessor));
  61. exports.SuiteNumberingProcessor = SuiteNumberingProcessor;
  62. //# sourceMappingURL=suite-numbering-processor.js.map