Convert Suite and SuiteMetadata to ES6 classes
This commit is contained in:
@@ -10475,7 +10475,8 @@ getJasmineRequireObj().StackTrace = function(j$) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
getJasmineRequireObj().Suite = function(j$) {
|
getJasmineRequireObj().Suite = function(j$) {
|
||||||
function Suite(attrs) {
|
class Suite {
|
||||||
|
constructor(attrs) {
|
||||||
this.env = attrs.env;
|
this.env = attrs.env;
|
||||||
this.id = attrs.id;
|
this.id = attrs.id;
|
||||||
this.parentSuite = attrs.parentSuite;
|
this.parentSuite = attrs.parentSuite;
|
||||||
@@ -10486,7 +10487,9 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
this.asyncExpectationFactory = attrs.asyncExpectationFactory;
|
this.asyncExpectationFactory = attrs.asyncExpectationFactory;
|
||||||
this.throwOnExpectationFailure = !!attrs.throwOnExpectationFailure;
|
this.throwOnExpectationFailure = !!attrs.throwOnExpectationFailure;
|
||||||
this.autoCleanClosures =
|
this.autoCleanClosures =
|
||||||
attrs.autoCleanClosures === undefined ? true : !!attrs.autoCleanClosures;
|
attrs.autoCleanClosures === undefined
|
||||||
|
? true
|
||||||
|
: !!attrs.autoCleanClosures;
|
||||||
this.onLateError = attrs.onLateError || function() {};
|
this.onLateError = attrs.onLateError || function() {};
|
||||||
|
|
||||||
this.beforeFns = [];
|
this.beforeFns = [];
|
||||||
@@ -10499,12 +10502,12 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
this.reset();
|
this.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
Suite.prototype.setSuiteProperty = function(key, value) {
|
setSuiteProperty(key, value) {
|
||||||
this.result.properties = this.result.properties || {};
|
this.result.properties = this.result.properties || {};
|
||||||
this.result.properties[key] = value;
|
this.result.properties[key] = value;
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.getFullName = function() {
|
getFullName() {
|
||||||
const fullName = [];
|
const fullName = [];
|
||||||
for (
|
for (
|
||||||
let parentSuite = this;
|
let parentSuite = this;
|
||||||
@@ -10516,64 +10519,54 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fullName.join(' ');
|
return fullName.join(' ');
|
||||||
};
|
}
|
||||||
|
|
||||||
/*
|
// Mark the suite with "pending" status
|
||||||
* Mark the suite with "pending" status
|
pend() {
|
||||||
*/
|
|
||||||
Suite.prototype.pend = function() {
|
|
||||||
this.markedPending = true;
|
this.markedPending = true;
|
||||||
};
|
}
|
||||||
|
|
||||||
/*
|
// Like pend(), but pending state will survive reset().
|
||||||
* Like {@link Suite#pend}, but pending state will survive {@link Spec#reset}
|
// Useful for fdescribe, xdescribe, where pending state should remain.
|
||||||
* Useful for fdescribe, xdescribe, where pending state should remain.
|
exclude() {
|
||||||
*/
|
|
||||||
Suite.prototype.exclude = function() {
|
|
||||||
this.pend();
|
this.pend();
|
||||||
this.markedExcluding = true;
|
this.markedExcluding = true;
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.beforeEach = function(fn) {
|
beforeEach(fn) {
|
||||||
this.beforeFns.unshift({ ...fn, suite: this });
|
this.beforeFns.unshift({ ...fn, suite: this });
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.beforeAll = function(fn) {
|
beforeAll(fn) {
|
||||||
this.beforeAllFns.push({ ...fn, type: 'beforeAll', suite: this });
|
this.beforeAllFns.push({ ...fn, type: 'beforeAll', suite: this });
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.afterEach = function(fn) {
|
afterEach(fn) {
|
||||||
this.afterFns.unshift({ ...fn, suite: this, type: 'afterEach' });
|
this.afterFns.unshift({ ...fn, suite: this, type: 'afterEach' });
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.afterAll = function(fn) {
|
afterAll(fn) {
|
||||||
this.afterAllFns.unshift({ ...fn, type: 'afterAll' });
|
this.afterAllFns.unshift({ ...fn, type: 'afterAll' });
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.startTimer = function() {
|
startTimer() {
|
||||||
this.timer.start();
|
this.timer.start();
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.endTimer = function() {
|
endTimer() {
|
||||||
this.result.duration = this.timer.elapsed();
|
this.result.duration = this.timer.elapsed();
|
||||||
};
|
|
||||||
|
|
||||||
function removeFns(queueableFns) {
|
|
||||||
for (const qf of queueableFns) {
|
|
||||||
qf.fn = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Suite.prototype.cleanupBeforeAfter = function() {
|
cleanupBeforeAfter() {
|
||||||
if (this.autoCleanClosures) {
|
if (this.autoCleanClosures) {
|
||||||
removeFns(this.beforeAllFns);
|
removeFns(this.beforeAllFns);
|
||||||
removeFns(this.afterAllFns);
|
removeFns(this.afterAllFns);
|
||||||
removeFns(this.beforeFns);
|
removeFns(this.beforeFns);
|
||||||
removeFns(this.afterFns);
|
removeFns(this.afterFns);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.reset = function() {
|
reset() {
|
||||||
/**
|
/**
|
||||||
* @typedef SuiteResult
|
* @typedef SuiteResult
|
||||||
* @property {String} id - The unique id of this suite.
|
* @property {String} id - The unique id of this suite.
|
||||||
@@ -10609,17 +10602,17 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
child.reset();
|
child.reset();
|
||||||
});
|
});
|
||||||
this.reportedDone = false;
|
this.reportedDone = false;
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.removeChildren = function() {
|
removeChildren() {
|
||||||
this.children = [];
|
this.children = [];
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.addChild = function(child) {
|
addChild(child) {
|
||||||
this.children.push(child);
|
this.children.push(child);
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.status = function() {
|
status() {
|
||||||
if (this.markedPending) {
|
if (this.markedPending) {
|
||||||
return 'pending';
|
return 'pending';
|
||||||
}
|
}
|
||||||
@@ -10629,18 +10622,18 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
} else {
|
} else {
|
||||||
return 'passed';
|
return 'passed';
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.canBeReentered = function() {
|
getResult() {
|
||||||
return this.beforeAllFns.length === 0 && this.afterAllFns.length === 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
Suite.prototype.getResult = function() {
|
|
||||||
this.result.status = this.status();
|
this.result.status = this.status();
|
||||||
return this.result;
|
return this.result;
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.sharedUserContext = function() {
|
canBeReentered() {
|
||||||
|
return this.beforeAllFns.length === 0 && this.afterAllFns.length === 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
sharedUserContext() {
|
||||||
if (!this.sharedContext) {
|
if (!this.sharedContext) {
|
||||||
this.sharedContext = this.parentSuite
|
this.sharedContext = this.parentSuite
|
||||||
? this.parentSuite.clonedSharedUserContext()
|
? this.parentSuite.clonedSharedUserContext()
|
||||||
@@ -10648,13 +10641,13 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return this.sharedContext;
|
return this.sharedContext;
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.clonedSharedUserContext = function() {
|
clonedSharedUserContext() {
|
||||||
return j$.UserContext.fromExisting(this.sharedUserContext());
|
return j$.UserContext.fromExisting(this.sharedUserContext());
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.handleException = function() {
|
handleException() {
|
||||||
if (arguments[0] instanceof j$.errors.ExpectationFailed) {
|
if (arguments[0] instanceof j$.errors.ExpectationFailed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -10677,12 +10670,12 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
} else {
|
} else {
|
||||||
this.result.failedExpectations.push(failedExpectation);
|
this.result.failedExpectations.push(failedExpectation);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.onMultipleDone = function() {
|
onMultipleDone() {
|
||||||
let msg;
|
let msg;
|
||||||
|
|
||||||
// Issue a deprecation. Include the context ourselves and pass
|
// Issue an error. Include the context ourselves and pass
|
||||||
// ignoreRunnable: true, since getting here always means that we've already
|
// ignoreRunnable: true, since getting here always means that we've already
|
||||||
// moved on and the current runnable isn't the one that caused the problem.
|
// moved on and the current runnable isn't the one that caused the problem.
|
||||||
if (this.parentSuite) {
|
if (this.parentSuite) {
|
||||||
@@ -10699,9 +10692,9 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.onLateError(new Error(msg));
|
this.onLateError(new Error(msg));
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.addExpectationResult = function() {
|
addExpectationResult() {
|
||||||
if (isFailure(arguments)) {
|
if (isFailure(arguments)) {
|
||||||
const data = arguments[1];
|
const data = arguments[1];
|
||||||
const expectationResult = j$.buildExpectationResult(data);
|
const expectationResult = j$.buildExpectationResult(data);
|
||||||
@@ -10721,18 +10714,18 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
throw new j$.errors.ExpectationFailed();
|
throw new j$.errors.ExpectationFailed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.addDeprecationWarning = function(deprecation) {
|
addDeprecationWarning(deprecation) {
|
||||||
if (typeof deprecation === 'string') {
|
if (typeof deprecation === 'string') {
|
||||||
deprecation = { message: deprecation };
|
deprecation = { message: deprecation };
|
||||||
}
|
}
|
||||||
this.result.deprecationWarnings.push(
|
this.result.deprecationWarnings.push(
|
||||||
j$.buildExpectationResult(deprecation)
|
j$.buildExpectationResult(deprecation)
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.hasChildWithDescription = function(description) {
|
hasChildWithDescription(description) {
|
||||||
for (const child of this.children) {
|
for (const child of this.children) {
|
||||||
if (child.description === description) {
|
if (child.description === description) {
|
||||||
return true;
|
return true;
|
||||||
@@ -10740,25 +10733,33 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
};
|
}
|
||||||
|
|
||||||
Object.defineProperty(Suite.prototype, 'metadata', {
|
get metadata() {
|
||||||
get: function() {
|
|
||||||
if (!this.metadata_) {
|
if (!this.metadata_) {
|
||||||
this.metadata_ = new SuiteMetadata(this);
|
this.metadata_ = new SuiteMetadata(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.metadata_;
|
return this.metadata_;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
function removeFns(queueableFns) {
|
||||||
|
for (const qf of queueableFns) {
|
||||||
|
qf.fn = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @interface Suite
|
* @interface Suite
|
||||||
* @see Env#topSuite
|
* @see Env#topSuite
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
function SuiteMetadata(suite) {
|
class SuiteMetadata {
|
||||||
this.suite_ = suite;
|
#suite;
|
||||||
|
|
||||||
|
constructor(suite) {
|
||||||
|
this.#suite = suite;
|
||||||
/**
|
/**
|
||||||
* The unique ID of this suite.
|
* The unique ID of this suite.
|
||||||
* @name Suite#id
|
* @name Suite#id
|
||||||
@@ -10793,9 +10794,9 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
SuiteMetadata.prototype.getFullName = function() {
|
getFullName() {
|
||||||
return this.suite_.getFullName();
|
return this.#suite.getFullName();
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The suite's children.
|
* The suite's children.
|
||||||
@@ -10803,11 +10804,10 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
* @type {Array.<(Spec|Suite)>}
|
* @type {Array.<(Spec|Suite)>}
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
Object.defineProperty(SuiteMetadata.prototype, 'children', {
|
get children() {
|
||||||
get: function() {
|
return this.#suite.children.map(child => child.metadata);
|
||||||
return this.suite_.children.map(child => child.metadata);
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
function isFailure(args) {
|
function isFailure(args) {
|
||||||
return !args[0];
|
return !args[0];
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
getJasmineRequireObj().Suite = function(j$) {
|
getJasmineRequireObj().Suite = function(j$) {
|
||||||
function Suite(attrs) {
|
class Suite {
|
||||||
|
constructor(attrs) {
|
||||||
this.env = attrs.env;
|
this.env = attrs.env;
|
||||||
this.id = attrs.id;
|
this.id = attrs.id;
|
||||||
this.parentSuite = attrs.parentSuite;
|
this.parentSuite = attrs.parentSuite;
|
||||||
@@ -10,7 +11,9 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
this.asyncExpectationFactory = attrs.asyncExpectationFactory;
|
this.asyncExpectationFactory = attrs.asyncExpectationFactory;
|
||||||
this.throwOnExpectationFailure = !!attrs.throwOnExpectationFailure;
|
this.throwOnExpectationFailure = !!attrs.throwOnExpectationFailure;
|
||||||
this.autoCleanClosures =
|
this.autoCleanClosures =
|
||||||
attrs.autoCleanClosures === undefined ? true : !!attrs.autoCleanClosures;
|
attrs.autoCleanClosures === undefined
|
||||||
|
? true
|
||||||
|
: !!attrs.autoCleanClosures;
|
||||||
this.onLateError = attrs.onLateError || function() {};
|
this.onLateError = attrs.onLateError || function() {};
|
||||||
|
|
||||||
this.beforeFns = [];
|
this.beforeFns = [];
|
||||||
@@ -23,12 +26,12 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
this.reset();
|
this.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
Suite.prototype.setSuiteProperty = function(key, value) {
|
setSuiteProperty(key, value) {
|
||||||
this.result.properties = this.result.properties || {};
|
this.result.properties = this.result.properties || {};
|
||||||
this.result.properties[key] = value;
|
this.result.properties[key] = value;
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.getFullName = function() {
|
getFullName() {
|
||||||
const fullName = [];
|
const fullName = [];
|
||||||
for (
|
for (
|
||||||
let parentSuite = this;
|
let parentSuite = this;
|
||||||
@@ -40,64 +43,54 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fullName.join(' ');
|
return fullName.join(' ');
|
||||||
};
|
}
|
||||||
|
|
||||||
/*
|
// Mark the suite with "pending" status
|
||||||
* Mark the suite with "pending" status
|
pend() {
|
||||||
*/
|
|
||||||
Suite.prototype.pend = function() {
|
|
||||||
this.markedPending = true;
|
this.markedPending = true;
|
||||||
};
|
}
|
||||||
|
|
||||||
/*
|
// Like pend(), but pending state will survive reset().
|
||||||
* Like {@link Suite#pend}, but pending state will survive {@link Spec#reset}
|
// Useful for fdescribe, xdescribe, where pending state should remain.
|
||||||
* Useful for fdescribe, xdescribe, where pending state should remain.
|
exclude() {
|
||||||
*/
|
|
||||||
Suite.prototype.exclude = function() {
|
|
||||||
this.pend();
|
this.pend();
|
||||||
this.markedExcluding = true;
|
this.markedExcluding = true;
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.beforeEach = function(fn) {
|
beforeEach(fn) {
|
||||||
this.beforeFns.unshift({ ...fn, suite: this });
|
this.beforeFns.unshift({ ...fn, suite: this });
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.beforeAll = function(fn) {
|
beforeAll(fn) {
|
||||||
this.beforeAllFns.push({ ...fn, type: 'beforeAll', suite: this });
|
this.beforeAllFns.push({ ...fn, type: 'beforeAll', suite: this });
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.afterEach = function(fn) {
|
afterEach(fn) {
|
||||||
this.afterFns.unshift({ ...fn, suite: this, type: 'afterEach' });
|
this.afterFns.unshift({ ...fn, suite: this, type: 'afterEach' });
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.afterAll = function(fn) {
|
afterAll(fn) {
|
||||||
this.afterAllFns.unshift({ ...fn, type: 'afterAll' });
|
this.afterAllFns.unshift({ ...fn, type: 'afterAll' });
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.startTimer = function() {
|
startTimer() {
|
||||||
this.timer.start();
|
this.timer.start();
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.endTimer = function() {
|
endTimer() {
|
||||||
this.result.duration = this.timer.elapsed();
|
this.result.duration = this.timer.elapsed();
|
||||||
};
|
|
||||||
|
|
||||||
function removeFns(queueableFns) {
|
|
||||||
for (const qf of queueableFns) {
|
|
||||||
qf.fn = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Suite.prototype.cleanupBeforeAfter = function() {
|
cleanupBeforeAfter() {
|
||||||
if (this.autoCleanClosures) {
|
if (this.autoCleanClosures) {
|
||||||
removeFns(this.beforeAllFns);
|
removeFns(this.beforeAllFns);
|
||||||
removeFns(this.afterAllFns);
|
removeFns(this.afterAllFns);
|
||||||
removeFns(this.beforeFns);
|
removeFns(this.beforeFns);
|
||||||
removeFns(this.afterFns);
|
removeFns(this.afterFns);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.reset = function() {
|
reset() {
|
||||||
/**
|
/**
|
||||||
* @typedef SuiteResult
|
* @typedef SuiteResult
|
||||||
* @property {String} id - The unique id of this suite.
|
* @property {String} id - The unique id of this suite.
|
||||||
@@ -133,17 +126,17 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
child.reset();
|
child.reset();
|
||||||
});
|
});
|
||||||
this.reportedDone = false;
|
this.reportedDone = false;
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.removeChildren = function() {
|
removeChildren() {
|
||||||
this.children = [];
|
this.children = [];
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.addChild = function(child) {
|
addChild(child) {
|
||||||
this.children.push(child);
|
this.children.push(child);
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.status = function() {
|
status() {
|
||||||
if (this.markedPending) {
|
if (this.markedPending) {
|
||||||
return 'pending';
|
return 'pending';
|
||||||
}
|
}
|
||||||
@@ -153,18 +146,18 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
} else {
|
} else {
|
||||||
return 'passed';
|
return 'passed';
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.canBeReentered = function() {
|
getResult() {
|
||||||
return this.beforeAllFns.length === 0 && this.afterAllFns.length === 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
Suite.prototype.getResult = function() {
|
|
||||||
this.result.status = this.status();
|
this.result.status = this.status();
|
||||||
return this.result;
|
return this.result;
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.sharedUserContext = function() {
|
canBeReentered() {
|
||||||
|
return this.beforeAllFns.length === 0 && this.afterAllFns.length === 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
sharedUserContext() {
|
||||||
if (!this.sharedContext) {
|
if (!this.sharedContext) {
|
||||||
this.sharedContext = this.parentSuite
|
this.sharedContext = this.parentSuite
|
||||||
? this.parentSuite.clonedSharedUserContext()
|
? this.parentSuite.clonedSharedUserContext()
|
||||||
@@ -172,13 +165,13 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return this.sharedContext;
|
return this.sharedContext;
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.clonedSharedUserContext = function() {
|
clonedSharedUserContext() {
|
||||||
return j$.UserContext.fromExisting(this.sharedUserContext());
|
return j$.UserContext.fromExisting(this.sharedUserContext());
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.handleException = function() {
|
handleException() {
|
||||||
if (arguments[0] instanceof j$.errors.ExpectationFailed) {
|
if (arguments[0] instanceof j$.errors.ExpectationFailed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -201,12 +194,12 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
} else {
|
} else {
|
||||||
this.result.failedExpectations.push(failedExpectation);
|
this.result.failedExpectations.push(failedExpectation);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.onMultipleDone = function() {
|
onMultipleDone() {
|
||||||
let msg;
|
let msg;
|
||||||
|
|
||||||
// Issue a deprecation. Include the context ourselves and pass
|
// Issue an error. Include the context ourselves and pass
|
||||||
// ignoreRunnable: true, since getting here always means that we've already
|
// ignoreRunnable: true, since getting here always means that we've already
|
||||||
// moved on and the current runnable isn't the one that caused the problem.
|
// moved on and the current runnable isn't the one that caused the problem.
|
||||||
if (this.parentSuite) {
|
if (this.parentSuite) {
|
||||||
@@ -223,9 +216,9 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.onLateError(new Error(msg));
|
this.onLateError(new Error(msg));
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.addExpectationResult = function() {
|
addExpectationResult() {
|
||||||
if (isFailure(arguments)) {
|
if (isFailure(arguments)) {
|
||||||
const data = arguments[1];
|
const data = arguments[1];
|
||||||
const expectationResult = j$.buildExpectationResult(data);
|
const expectationResult = j$.buildExpectationResult(data);
|
||||||
@@ -245,18 +238,18 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
throw new j$.errors.ExpectationFailed();
|
throw new j$.errors.ExpectationFailed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.addDeprecationWarning = function(deprecation) {
|
addDeprecationWarning(deprecation) {
|
||||||
if (typeof deprecation === 'string') {
|
if (typeof deprecation === 'string') {
|
||||||
deprecation = { message: deprecation };
|
deprecation = { message: deprecation };
|
||||||
}
|
}
|
||||||
this.result.deprecationWarnings.push(
|
this.result.deprecationWarnings.push(
|
||||||
j$.buildExpectationResult(deprecation)
|
j$.buildExpectationResult(deprecation)
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
Suite.prototype.hasChildWithDescription = function(description) {
|
hasChildWithDescription(description) {
|
||||||
for (const child of this.children) {
|
for (const child of this.children) {
|
||||||
if (child.description === description) {
|
if (child.description === description) {
|
||||||
return true;
|
return true;
|
||||||
@@ -264,25 +257,33 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
};
|
}
|
||||||
|
|
||||||
Object.defineProperty(Suite.prototype, 'metadata', {
|
get metadata() {
|
||||||
get: function() {
|
|
||||||
if (!this.metadata_) {
|
if (!this.metadata_) {
|
||||||
this.metadata_ = new SuiteMetadata(this);
|
this.metadata_ = new SuiteMetadata(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.metadata_;
|
return this.metadata_;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
function removeFns(queueableFns) {
|
||||||
|
for (const qf of queueableFns) {
|
||||||
|
qf.fn = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @interface Suite
|
* @interface Suite
|
||||||
* @see Env#topSuite
|
* @see Env#topSuite
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
function SuiteMetadata(suite) {
|
class SuiteMetadata {
|
||||||
this.suite_ = suite;
|
#suite;
|
||||||
|
|
||||||
|
constructor(suite) {
|
||||||
|
this.#suite = suite;
|
||||||
/**
|
/**
|
||||||
* The unique ID of this suite.
|
* The unique ID of this suite.
|
||||||
* @name Suite#id
|
* @name Suite#id
|
||||||
@@ -317,9 +318,9 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
SuiteMetadata.prototype.getFullName = function() {
|
getFullName() {
|
||||||
return this.suite_.getFullName();
|
return this.#suite.getFullName();
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The suite's children.
|
* The suite's children.
|
||||||
@@ -327,11 +328,10 @@ getJasmineRequireObj().Suite = function(j$) {
|
|||||||
* @type {Array.<(Spec|Suite)>}
|
* @type {Array.<(Spec|Suite)>}
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
Object.defineProperty(SuiteMetadata.prototype, 'children', {
|
get children() {
|
||||||
get: function() {
|
return this.#suite.children.map(child => child.metadata);
|
||||||
return this.suite_.children.map(child => child.metadata);
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
function isFailure(args) {
|
function isFailure(args) {
|
||||||
return !args[0];
|
return !args[0];
|
||||||
|
|||||||
Reference in New Issue
Block a user