Simplify HtmlReporterV2 initialization and boot1.js
This commit is contained in:
@@ -19,12 +19,12 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
|
||||
* const reporter = new jasmine.HtmlReporterV2({
|
||||
* env,
|
||||
* urls,
|
||||
* getContainer: () => document.body
|
||||
* // container is optional and defaults to document.body.
|
||||
* container: someElement
|
||||
* });
|
||||
*/
|
||||
class HtmlReporterV2 {
|
||||
#env;
|
||||
#getContainer;
|
||||
#container;
|
||||
#queryString;
|
||||
#urlBuilder;
|
||||
#filterSpecs;
|
||||
@@ -41,9 +41,7 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
|
||||
#failures;
|
||||
|
||||
constructor(options) {
|
||||
this.#env = options.env;
|
||||
|
||||
this.#getContainer = options.getContainer;
|
||||
this.#container = options.container || document.body;
|
||||
this.#queryString =
|
||||
options.queryString ||
|
||||
new j$.QueryString({
|
||||
@@ -56,16 +54,8 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
|
||||
getSuiteById: id => this.#stateBuilder.suitesById[id]
|
||||
});
|
||||
this.#filterSpecs = options.urls.filteringSpecs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the reporter. Should be called before {@link Env#execute}.
|
||||
* @function
|
||||
* @name HtmlReporter#initialize
|
||||
*/
|
||||
initialize() {
|
||||
this.#clearPrior();
|
||||
this.#config = this.#env ? this.#env.configuration() : {};
|
||||
this.#config = options.env ? options.env.configuration() : {};
|
||||
|
||||
this.#stateBuilder = new j$.private.ResultsStateBuilder();
|
||||
|
||||
@@ -106,7 +96,7 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
|
||||
this.#alerts.rootEl,
|
||||
this.#failures.rootEl
|
||||
);
|
||||
this.#getContainer().appendChild(this.#htmlReporterMain);
|
||||
this.#container.appendChild(this.#htmlReporterMain);
|
||||
this.#failures.show();
|
||||
}
|
||||
|
||||
@@ -199,19 +189,11 @@ jasmineRequire.HtmlReporterV2 = function(j$) {
|
||||
}
|
||||
|
||||
#find(selector) {
|
||||
return this.#getContainer().querySelector(
|
||||
return this.#container.querySelector(
|
||||
'.jasmine_html-reporter ' + selector
|
||||
);
|
||||
}
|
||||
|
||||
#clearPrior() {
|
||||
const oldReporter = this.#find('');
|
||||
|
||||
if (oldReporter) {
|
||||
this.#getContainer().removeChild(oldReporter);
|
||||
}
|
||||
}
|
||||
|
||||
#setMenuModeTo(mode) {
|
||||
this.#htmlReporterMain.setAttribute(
|
||||
'class',
|
||||
|
||||
Reference in New Issue
Block a user