Convert ParallelReportDispatcher to an ES6 class
ParallelReportDispatcher itself doesn't gain anything from this, but it'll allow monkey patching prevention to be implemented and tested more uniformly.
This commit is contained in:
@@ -7966,8 +7966,10 @@ getJasmineRequireObj().ParallelReportDispatcher = function(j$, private$) {
|
||||
* Jasmine specs run in. Doing so will break Jasmine's error handling.
|
||||
* @param onError {function} Function called when an unhandled exception, unhandled promise rejection, or explicit reporter failure occurs
|
||||
*/
|
||||
function ParallelReportDispatcher(onError, deps = {}) {
|
||||
const ReportDispatcher = deps.ReportDispatcher || private$.ReportDispatcher;
|
||||
class ParallelReportDispatcher {
|
||||
constructor(onError, deps = {}) {
|
||||
const ReportDispatcher =
|
||||
deps.ReportDispatcher || private$.ReportDispatcher;
|
||||
const QueueRunner = deps.QueueRunner || private$.QueueRunner;
|
||||
const globalErrors = deps.globalErrors || new private$.GlobalErrors();
|
||||
const dispatcher = new ReportDispatcher(
|
||||
@@ -8001,7 +8003,6 @@ getJasmineRequireObj().ParallelReportDispatcher = function(j$, private$) {
|
||||
}
|
||||
);
|
||||
|
||||
const self = {
|
||||
/**
|
||||
* Adds a reporter to the list of reporters that events will be dispatched to.
|
||||
* @function
|
||||
@@ -8009,13 +8010,13 @@ getJasmineRequireObj().ParallelReportDispatcher = function(j$, private$) {
|
||||
* @param {Reporter} reporterToAdd The reporter to be added.
|
||||
* @see custom_reporter
|
||||
*/
|
||||
addReporter: dispatcher.addReporter.bind(dispatcher),
|
||||
this.addReporter = dispatcher.addReporter.bind(dispatcher);
|
||||
/**
|
||||
* Clears all registered reporters.
|
||||
* @function
|
||||
* @name ParallelReportDispatcher#clearReporters
|
||||
*/
|
||||
clearReporters: dispatcher.clearReporters.bind(dispatcher),
|
||||
this.clearReporters = dispatcher.clearReporters.bind(dispatcher);
|
||||
/**
|
||||
* Installs a global error handler. After this method is called, any
|
||||
* unhandled exceptions or unhandled promise rejections will be passed to
|
||||
@@ -8023,23 +8024,21 @@ getJasmineRequireObj().ParallelReportDispatcher = function(j$, private$) {
|
||||
* @function
|
||||
* @name ParallelReportDispatcher#installGlobalErrors
|
||||
*/
|
||||
installGlobalErrors: globalErrors.install.bind(globalErrors),
|
||||
this.installGlobalErrors = globalErrors.install.bind(globalErrors);
|
||||
/**
|
||||
* Uninstalls the global error handler.
|
||||
* @function
|
||||
* @name ParallelReportDispatcher#uninstallGlobalErrors
|
||||
*/
|
||||
uninstallGlobalErrors: function() {
|
||||
this.uninstallGlobalErrors = function() {
|
||||
// late-bind uninstall because it doesn't exist until install is called
|
||||
globalErrors.uninstall(globalErrors);
|
||||
}
|
||||
};
|
||||
|
||||
for (const eventName of private$.reporterEvents) {
|
||||
self[eventName] = dispatcher[eventName].bind(dispatcher);
|
||||
this[eventName] = dispatcher[eventName].bind(dispatcher);
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
return ParallelReportDispatcher;
|
||||
|
||||
@@ -15,8 +15,10 @@ getJasmineRequireObj().ParallelReportDispatcher = function(j$, private$) {
|
||||
* Jasmine specs run in. Doing so will break Jasmine's error handling.
|
||||
* @param onError {function} Function called when an unhandled exception, unhandled promise rejection, or explicit reporter failure occurs
|
||||
*/
|
||||
function ParallelReportDispatcher(onError, deps = {}) {
|
||||
const ReportDispatcher = deps.ReportDispatcher || private$.ReportDispatcher;
|
||||
class ParallelReportDispatcher {
|
||||
constructor(onError, deps = {}) {
|
||||
const ReportDispatcher =
|
||||
deps.ReportDispatcher || private$.ReportDispatcher;
|
||||
const QueueRunner = deps.QueueRunner || private$.QueueRunner;
|
||||
const globalErrors = deps.globalErrors || new private$.GlobalErrors();
|
||||
const dispatcher = new ReportDispatcher(
|
||||
@@ -50,7 +52,6 @@ getJasmineRequireObj().ParallelReportDispatcher = function(j$, private$) {
|
||||
}
|
||||
);
|
||||
|
||||
const self = {
|
||||
/**
|
||||
* Adds a reporter to the list of reporters that events will be dispatched to.
|
||||
* @function
|
||||
@@ -58,13 +59,13 @@ getJasmineRequireObj().ParallelReportDispatcher = function(j$, private$) {
|
||||
* @param {Reporter} reporterToAdd The reporter to be added.
|
||||
* @see custom_reporter
|
||||
*/
|
||||
addReporter: dispatcher.addReporter.bind(dispatcher),
|
||||
this.addReporter = dispatcher.addReporter.bind(dispatcher);
|
||||
/**
|
||||
* Clears all registered reporters.
|
||||
* @function
|
||||
* @name ParallelReportDispatcher#clearReporters
|
||||
*/
|
||||
clearReporters: dispatcher.clearReporters.bind(dispatcher),
|
||||
this.clearReporters = dispatcher.clearReporters.bind(dispatcher);
|
||||
/**
|
||||
* Installs a global error handler. After this method is called, any
|
||||
* unhandled exceptions or unhandled promise rejections will be passed to
|
||||
@@ -72,23 +73,21 @@ getJasmineRequireObj().ParallelReportDispatcher = function(j$, private$) {
|
||||
* @function
|
||||
* @name ParallelReportDispatcher#installGlobalErrors
|
||||
*/
|
||||
installGlobalErrors: globalErrors.install.bind(globalErrors),
|
||||
this.installGlobalErrors = globalErrors.install.bind(globalErrors);
|
||||
/**
|
||||
* Uninstalls the global error handler.
|
||||
* @function
|
||||
* @name ParallelReportDispatcher#uninstallGlobalErrors
|
||||
*/
|
||||
uninstallGlobalErrors: function() {
|
||||
this.uninstallGlobalErrors = function() {
|
||||
// late-bind uninstall because it doesn't exist until install is called
|
||||
globalErrors.uninstall(globalErrors);
|
||||
}
|
||||
};
|
||||
|
||||
for (const eventName of private$.reporterEvents) {
|
||||
self[eventName] = dispatcher[eventName].bind(dispatcher);
|
||||
this[eventName] = dispatcher[eventName].bind(dispatcher);
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
return ParallelReportDispatcher;
|
||||
|
||||
Reference in New Issue
Block a user