Clarify what's currently treated as private vs internal in Suite and Spec

This commit is contained in:
Steve Gravrock
2025-08-31 09:18:16 -07:00
parent e1532be726
commit ca4fbcbccb
6 changed files with 99 additions and 102 deletions

View File

@@ -772,6 +772,11 @@ getJasmineRequireObj().util = function(j$) {
getJasmineRequireObj().Spec = function(j$) {
class Spec {
#autoCleanClosures;
#throwOnExpectationFailure;
#timer;
#metadata;
constructor(attrs) {
this.expectationFactory = attrs.expectationFactory;
this.asyncExpectationFactory = attrs.asyncExpectationFactory;
@@ -790,23 +795,17 @@ getJasmineRequireObj().Spec = function(j$) {
function() {
return {};
};
this.autoCleanClosures =
attrs.autoCleanClosures === undefined
? true
: !!attrs.autoCleanClosures;
this.getPath = function() {
return attrs.getPath ? attrs.getPath(this) : [];
};
this.#autoCleanClosures =
attrs.autoCleanClosures === undefined
? true
: !!attrs.autoCleanClosures;
this.onLateError = attrs.onLateError || function() {};
this.catchingExceptions =
attrs.catchingExceptions ||
function() {
return true;
};
this.throwOnExpectationFailure = !!attrs.throwOnExpectationFailure;
this.timer = attrs.timer || new j$.Timer();
this.#throwOnExpectationFailure = !!attrs.throwOnExpectationFailure;
this.#timer = attrs.timer || new j$.Timer();
if (!this.queueableFn.fn) {
this.exclude();
@@ -832,7 +831,7 @@ getJasmineRequireObj().Spec = function(j$) {
}
}
if (this.throwOnExpectationFailure && !isError) {
if (this.#throwOnExpectationFailure && !isError) {
throw new j$.errors.ExpectationFailed();
}
}
@@ -849,16 +848,16 @@ getJasmineRequireObj().Spec = function(j$) {
}
executionStarted() {
this.timer.start();
this.#timer.start();
}
executionFinished(excluded, failSpecWithNoExp) {
if (this.autoCleanClosures) {
if (this.#autoCleanClosures) {
this.queueableFn.fn = null;
}
this.result.status = this.status(excluded, failSpecWithNoExp);
this.result.duration = this.timer.elapsed();
this.result.status = this.#status(excluded, failSpecWithNoExp);
this.result.duration = this.#timer.elapsed();
if (this.result.status !== 'failed') {
this.result.debugLogs = null;
@@ -949,11 +948,11 @@ getJasmineRequireObj().Spec = function(j$) {
// TODO: ensure that all access to result goes through .getResult()
// so that the status is correct.
getResult() {
this.result.status = this.status();
this.result.status = this.#status();
return this.result;
}
status(excluded, failSpecWithNoExpectations) {
#status(excluded, failSpecWithNoExpectations) {
if (excluded === true) {
return 'excluded';
}
@@ -1001,7 +1000,7 @@ getJasmineRequireObj().Spec = function(j$) {
*/
this.result.debugLogs.push({
message: msg,
timestamp: this.timer.elapsed()
timestamp: this.#timer.elapsed()
});
}
@@ -1015,8 +1014,8 @@ getJasmineRequireObj().Spec = function(j$) {
// actual Spec instances are still passed to Configuration#specFilter. Until
// that is fixed, it's important to make sure that all metadata properties
// also exist in compatible form on the underlying Spec.
if (!this.metadata_) {
this.metadata_ = {
if (!this.#metadata) {
this.#metadata = {
/**
* The unique ID of this spec.
* @name Spec#id
@@ -1055,7 +1054,7 @@ getJasmineRequireObj().Spec = function(j$) {
};
}
return this.metadata_;
return this.#metadata;
}
}
@@ -10476,27 +10475,31 @@ getJasmineRequireObj().StackTrace = function(j$) {
getJasmineRequireObj().Suite = function(j$) {
class Suite {
#reportedParentSuiteId;
#throwOnExpectationFailure;
#autoCleanClosures;
#timer;
constructor(attrs) {
this.env = attrs.env;
this.id = attrs.id;
this.parentSuite = attrs.parentSuite;
this.description = attrs.description;
this.reportedParentSuiteId = attrs.reportedParentSuiteId;
this.filename = attrs.filename;
this.expectationFactory = attrs.expectationFactory;
this.asyncExpectationFactory = attrs.asyncExpectationFactory;
this.throwOnExpectationFailure = !!attrs.throwOnExpectationFailure;
this.autoCleanClosures =
this.onLateError = attrs.onLateError || function() {};
this.#reportedParentSuiteId = attrs.reportedParentSuiteId;
this.#throwOnExpectationFailure = !!attrs.throwOnExpectationFailure;
this.#autoCleanClosures =
attrs.autoCleanClosures === undefined
? true
: !!attrs.autoCleanClosures;
this.onLateError = attrs.onLateError || function() {};
this.#timer = attrs.timer || new j$.Timer();
this.beforeFns = [];
this.afterFns = [];
this.beforeAllFns = [];
this.afterAllFns = [];
this.timer = attrs.timer || new j$.Timer();
this.children = [];
this.reset();
@@ -10550,15 +10553,15 @@ getJasmineRequireObj().Suite = function(j$) {
}
startTimer() {
this.timer.start();
this.#timer.start();
}
endTimer() {
this.result.duration = this.timer.elapsed();
this.result.duration = this.#timer.elapsed();
}
cleanupBeforeAfter() {
if (this.autoCleanClosures) {
if (this.#autoCleanClosures) {
removeFns(this.beforeAllFns);
removeFns(this.afterAllFns);
removeFns(this.beforeFns);
@@ -10590,7 +10593,7 @@ getJasmineRequireObj().Suite = function(j$) {
id: this.id,
description: this.description,
fullName: this.getFullName(),
parentSuiteId: this.reportedParentSuiteId,
parentSuiteId: this.#reportedParentSuiteId,
filename: this.filename,
failedExpectations: [],
deprecationWarnings: [],
@@ -10612,7 +10615,7 @@ getJasmineRequireObj().Suite = function(j$) {
this.children.push(child);
}
status() {
#status() {
if (this.markedPending) {
return 'pending';
}
@@ -10625,7 +10628,7 @@ getJasmineRequireObj().Suite = function(j$) {
}
getResult() {
this.result.status = this.status();
this.result.status = this.#status();
return this.result;
}
@@ -10710,7 +10713,7 @@ getJasmineRequireObj().Suite = function(j$) {
}
}
if (this.throwOnExpectationFailure) {
if (this.#throwOnExpectationFailure) {
throw new j$.errors.ExpectationFailed();
}
}