suite-numbering-processor.js 2.4 KB

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