1 | ;
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', {
|
4 | value: true
|
5 | });
|
6 | exports.default = void 0;
|
7 |
|
8 | function _defineProperty(obj, key, value) {
|
9 | if (key in obj) {
|
10 | Object.defineProperty(obj, key, {
|
11 | value: value,
|
12 | enumerable: true,
|
13 | configurable: true,
|
14 | writable: true
|
15 | });
|
16 | } else {
|
17 | obj[key] = value;
|
18 | }
|
19 | return obj;
|
20 | }
|
21 |
|
22 | /**
|
23 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
24 | *
|
25 | * This source code is licensed under the MIT license found in the
|
26 | * LICENSE file in the root directory of this source tree.
|
27 | *
|
28 | */
|
29 | // This file is a heavily modified fork of Jasmine. Original license:
|
30 |
|
31 | /*
|
32 | Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
33 |
|
34 | Permission is hereby granted, free of charge, to any person obtaining
|
35 | a copy of this software and associated documentation files (the
|
36 | "Software"), to deal in the Software without restriction, including
|
37 | without limitation the rights to use, copy, modify, merge, publish,
|
38 | distribute, sublicense, and/or sell copies of the Software, and to
|
39 | permit persons to whom the Software is furnished to do so, subject to
|
40 | the following conditions:
|
41 |
|
42 | The above copyright notice and this permission notice shall be
|
43 | included in all copies or substantial portions of the Software.
|
44 |
|
45 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
46 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
47 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
48 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
49 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
50 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
51 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
52 | */
|
53 |
|
54 | /* eslint-disable local/prefer-spread-eventually, local/prefer-rest-params-eventually */
|
55 | class ReportDispatcher {
|
56 | // @ts-expect-error
|
57 | // @ts-expect-error
|
58 | // @ts-expect-error
|
59 | // @ts-expect-error
|
60 | // @ts-expect-error
|
61 | // @ts-expect-error
|
62 | constructor(methods) {
|
63 | _defineProperty(this, 'addReporter', void 0);
|
64 |
|
65 | _defineProperty(this, 'provideFallbackReporter', void 0);
|
66 |
|
67 | _defineProperty(this, 'clearReporters', void 0);
|
68 |
|
69 | _defineProperty(this, 'jasmineDone', void 0);
|
70 |
|
71 | _defineProperty(this, 'jasmineStarted', void 0);
|
72 |
|
73 | _defineProperty(this, 'specDone', void 0);
|
74 |
|
75 | _defineProperty(this, 'specStarted', void 0);
|
76 |
|
77 | _defineProperty(this, 'suiteDone', void 0);
|
78 |
|
79 | _defineProperty(this, 'suiteStarted', void 0);
|
80 |
|
81 | const dispatchedMethods = methods || [];
|
82 |
|
83 | for (let i = 0; i < dispatchedMethods.length; i++) {
|
84 | const method = dispatchedMethods[i];
|
85 |
|
86 | this[method] = (function (m) {
|
87 | return function () {
|
88 | dispatch(m, arguments);
|
89 | };
|
90 | })(method);
|
91 | }
|
92 |
|
93 | let reporters = [];
|
94 | let fallbackReporter = null;
|
95 |
|
96 | this.addReporter = function (reporter) {
|
97 | reporters.push(reporter);
|
98 | };
|
99 |
|
100 | this.provideFallbackReporter = function (reporter) {
|
101 | fallbackReporter = reporter;
|
102 | };
|
103 |
|
104 | this.clearReporters = function () {
|
105 | reporters = [];
|
106 | };
|
107 |
|
108 | return this;
|
109 |
|
110 | function dispatch(method, args) {
|
111 | if (reporters.length === 0 && fallbackReporter !== null) {
|
112 | reporters.push(fallbackReporter);
|
113 | }
|
114 |
|
115 | for (let i = 0; i < reporters.length; i++) {
|
116 | const reporter = reporters[i];
|
117 |
|
118 | if (reporter[method]) {
|
119 | // @ts-expect-error
|
120 | reporter[method].apply(reporter, args);
|
121 | }
|
122 | }
|
123 | }
|
124 | }
|
125 | }
|
126 |
|
127 | exports.default = ReportDispatcher;
|