execution-display.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.ExecutionDisplay = void 0;
  4. var ExecutionDisplay = /** @class */ (function () {
  5. function ExecutionDisplay(configuration, logger, specs, displayProcessors) {
  6. this.configuration = configuration;
  7. this.logger = logger;
  8. this.specs = specs;
  9. this.suiteHierarchy = [];
  10. this.suiteHierarchyDisplayed = [];
  11. this.hasCustomDisplaySpecStarted = ExecutionDisplay.hasCustomDisplaySpecStarted(displayProcessors);
  12. }
  13. ExecutionDisplay.hasCustomDisplaySpecStarted = function (processors) {
  14. var isDisplayed = false;
  15. processors.forEach(function (processor) {
  16. var log = "foo";
  17. var result = processor.displaySpecStarted({ id: "bar", description: "bar", fullName: "bar", duration: null, properties: null }, log);
  18. isDisplayed = isDisplayed || result !== log;
  19. });
  20. return isDisplayed;
  21. };
  22. ExecutionDisplay.prototype.jasmineStarted = function (suiteInfo) {
  23. this.logger.process(suiteInfo, function (displayProcessor, object, log) {
  24. return displayProcessor.displayJasmineStarted(object, log);
  25. });
  26. };
  27. ExecutionDisplay.prototype.specStarted = function (result) {
  28. if (this.hasCustomDisplaySpecStarted) {
  29. this.ensureSuiteDisplayed();
  30. this.logger.process(result, function (displayProcessor, object, log) {
  31. return displayProcessor.displaySpecStarted(object, log);
  32. });
  33. }
  34. };
  35. ExecutionDisplay.prototype.successful = function (result) {
  36. this.specs.successful.push(result);
  37. if (this.configuration.spec.displaySuccessful) {
  38. this.ensureSuiteDisplayed();
  39. this.logger.process(result, function (displayProcessor, object, log) {
  40. return displayProcessor.displaySuccessfulSpec(object, log);
  41. });
  42. }
  43. };
  44. ExecutionDisplay.prototype.failed = function (result) {
  45. this.specs.failed.push(result);
  46. if (this.configuration.spec.displayFailed) {
  47. this.ensureSuiteDisplayed();
  48. this.logger.process(result, function (displayProcessor, object, log) {
  49. return displayProcessor.displayFailedSpec(object, log);
  50. });
  51. if (this.configuration.spec.displayErrorMessages) {
  52. this.logger.increaseIndent();
  53. this.logger.process(result, function (displayProcessor, object, log) {
  54. return displayProcessor.displaySpecErrorMessages(object, log);
  55. });
  56. this.logger.decreaseIndent();
  57. }
  58. }
  59. };
  60. ExecutionDisplay.prototype.pending = function (result) {
  61. this.specs.pending.push(result);
  62. if (this.configuration.spec.displayPending) {
  63. this.ensureSuiteDisplayed();
  64. this.logger.process(result, function (displayProcessor, object, log) {
  65. return displayProcessor.displayPendingSpec(object, log);
  66. });
  67. }
  68. };
  69. ExecutionDisplay.prototype.suiteStarted = function (result) {
  70. this.suiteHierarchy.push(result);
  71. };
  72. ExecutionDisplay.prototype.suiteDone = function (result) {
  73. if (result && result.failedExpectations && result.failedExpectations.length) {
  74. this.failed(result);
  75. }
  76. var suite = this.suiteHierarchy.pop();
  77. if (this.suiteHierarchyDisplayed[this.suiteHierarchyDisplayed.length - 1] === suite) {
  78. this.suiteHierarchyDisplayed.pop();
  79. }
  80. this.logger.newLine();
  81. this.logger.decreaseIndent();
  82. };
  83. ExecutionDisplay.prototype.ensureSuiteDisplayed = function () {
  84. if (this.suiteHierarchy.length !== 0) {
  85. for (var i = this.suiteHierarchyDisplayed.length; i < this.suiteHierarchy.length; i++) {
  86. this.suiteHierarchyDisplayed.push(this.suiteHierarchy[i]);
  87. this.displaySuite(this.suiteHierarchy[i]);
  88. }
  89. }
  90. else {
  91. var name = "Top level suite";
  92. var topLevelSuite = {
  93. description: name,
  94. fullName: name,
  95. id: name,
  96. properties: null,
  97. duration: null
  98. };
  99. this.suiteHierarchy.push(topLevelSuite);
  100. this.suiteHierarchyDisplayed.push(topLevelSuite);
  101. this.displaySuite(topLevelSuite);
  102. }
  103. };
  104. ExecutionDisplay.prototype.displaySuite = function (suite) {
  105. this.logger.newLine();
  106. this.computeSuiteIndent();
  107. this.logger.process(suite, function (displayProcessor, object, log) {
  108. return displayProcessor.displaySuite(object, log);
  109. });
  110. this.logger.increaseIndent();
  111. };
  112. ExecutionDisplay.prototype.computeSuiteIndent = function () {
  113. var _this = this;
  114. this.logger.resetIndent();
  115. this.suiteHierarchyDisplayed.forEach(function () { return _this.logger.increaseIndent(); });
  116. };
  117. return ExecutionDisplay;
  118. }());
  119. exports.ExecutionDisplay = ExecutionDisplay;
  120. //# sourceMappingURL=execution-display.js.map