Deprecate HtmlReporter and HtmlSpecFilter

This commit is contained in:
Steve Gravrock
2025-10-09 07:02:39 -07:00
parent 0ad54fc6f0
commit 9b3cc08818
6 changed files with 50 additions and 4 deletions

View File

@@ -38,7 +38,7 @@ jasmineRequire.html = function(j$) {
j$.HtmlReporterV2Urls = jasmineRequire.HtmlReporterV2Urls(j$); j$.HtmlReporterV2Urls = jasmineRequire.HtmlReporterV2Urls(j$);
j$.HtmlReporterV2 = jasmineRequire.HtmlReporterV2(j$); j$.HtmlReporterV2 = jasmineRequire.HtmlReporterV2(j$);
j$.QueryString = jasmineRequire.QueryString(); j$.QueryString = jasmineRequire.QueryString();
j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter(); j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter(j$);
j$.private.HtmlSpecFilterV2 = jasmineRequire.HtmlSpecFilterV2(); j$.private.HtmlSpecFilterV2 = jasmineRequire.HtmlSpecFilterV2();
}; };
@@ -53,6 +53,7 @@ jasmineRequire.HtmlReporter = function(j$) {
* @implements {Reporter} * @implements {Reporter}
* @param options Options object. See lib/jasmine-core/boot1.js for details. * @param options Options object. See lib/jasmine-core/boot1.js for details.
* @since 1.2.0 * @since 1.2.0
* @deprecated
*/ */
class HtmlReporter { class HtmlReporter {
#env; #env;
@@ -88,6 +89,9 @@ jasmineRequire.HtmlReporter = function(j$) {
* @name HtmlReporter#initialize * @name HtmlReporter#initialize
*/ */
initialize() { initialize() {
this.#env.deprecated(
'HtmlReporter and HtmlSpecFilter are deprecated. Use HtmlReporterV2 instead.'
);
this.#clearPrior(); this.#clearPrior();
this.#config = this.#env ? this.#env.configuration() : {}; this.#config = this.#env ? this.#env.configuration() : {};
@@ -256,10 +260,14 @@ jasmineRequire.HtmlReporter = function(j$) {
return HtmlReporter; return HtmlReporter;
}; };
jasmineRequire.HtmlSpecFilter = function() { jasmineRequire.HtmlSpecFilter = function(j$) {
'use strict'; 'use strict';
function HtmlSpecFilter(options) { function HtmlSpecFilter(options) {
j$.getEnv().deprecated(
'HtmlReporter and HtmlSpecFilter are deprecated. Use HtmlReporterV2 instead.'
);
const filterString = const filterString =
options && options &&
options.filterString() && options.filterString() &&
@@ -272,6 +280,7 @@ jasmineRequire.HtmlSpecFilter = function() {
* @function * @function
* @param {string} specName The full name of the spec * @param {string} specName The full name of the spec
* @returns {boolean} * @returns {boolean}
* @deprcated
*/ */
this.matches = function(specName) { this.matches = function(specName) {
return filterPattern.test(specName); return filterPattern.test(specName);

View File

@@ -3,12 +3,29 @@ describe('HtmlReporter', function() {
beforeEach(function() { beforeEach(function() {
env = new privateUnderTest.Env(); env = new privateUnderTest.Env();
spyOn(env, 'deprecated');
}); });
afterEach(function() { afterEach(function() {
env.cleanup_(); env.cleanup_();
}); });
it('emits a deprecation warning', function() {
const container = document.createElement('div'),
getContainer = function() {
return container;
},
reporter = new jasmineUnderTest.HtmlReporter({
env: env,
getContainer: getContainer
});
reporter.initialize();
expect(env.deprecated).toHaveBeenCalledWith(
'HtmlReporter and HtmlSpecFilter are deprecated. Use HtmlReporterV2 instead.'
);
});
it('builds the initial DOM elements, including the title banner', function() { it('builds the initial DOM elements, including the title banner', function() {
const container = document.createElement('div'), const container = document.createElement('div'),
getContainer = function() { getContainer = function() {

View File

@@ -1,4 +1,15 @@
describe('HtmlSpecFilter', function() { describe('HtmlSpecFilter', function() {
beforeEach(function() {
spyOn(jasmineUnderTest.getEnv(), 'deprecated');
});
it('emits a deprecation warning', function() {
new jasmineUnderTest.HtmlSpecFilter();
expect(jasmineUnderTest.getEnv().deprecated).toHaveBeenCalledWith(
'HtmlReporter and HtmlSpecFilter are deprecated. Use HtmlReporterV2 instead.'
);
});
it('should match when no string is provided', function() { it('should match when no string is provided', function() {
const specFilter = new jasmineUnderTest.HtmlSpecFilter(); const specFilter = new jasmineUnderTest.HtmlSpecFilter();

View File

@@ -9,6 +9,7 @@ jasmineRequire.HtmlReporter = function(j$) {
* @implements {Reporter} * @implements {Reporter}
* @param options Options object. See lib/jasmine-core/boot1.js for details. * @param options Options object. See lib/jasmine-core/boot1.js for details.
* @since 1.2.0 * @since 1.2.0
* @deprecated
*/ */
class HtmlReporter { class HtmlReporter {
#env; #env;
@@ -44,6 +45,9 @@ jasmineRequire.HtmlReporter = function(j$) {
* @name HtmlReporter#initialize * @name HtmlReporter#initialize
*/ */
initialize() { initialize() {
this.#env.deprecated(
'HtmlReporter and HtmlSpecFilter are deprecated. Use HtmlReporterV2 instead.'
);
this.#clearPrior(); this.#clearPrior();
this.#config = this.#env ? this.#env.configuration() : {}; this.#config = this.#env ? this.#env.configuration() : {};

View File

@@ -1,7 +1,11 @@
jasmineRequire.HtmlSpecFilter = function() { jasmineRequire.HtmlSpecFilter = function(j$) {
'use strict'; 'use strict';
function HtmlSpecFilter(options) { function HtmlSpecFilter(options) {
j$.getEnv().deprecated(
'HtmlReporter and HtmlSpecFilter are deprecated. Use HtmlReporterV2 instead.'
);
const filterString = const filterString =
options && options &&
options.filterString() && options.filterString() &&
@@ -14,6 +18,7 @@ jasmineRequire.HtmlSpecFilter = function() {
* @function * @function
* @param {string} specName The full name of the spec * @param {string} specName The full name of the spec
* @returns {boolean} * @returns {boolean}
* @deprcated
*/ */
this.matches = function(specName) { this.matches = function(specName) {
return filterPattern.test(specName); return filterPattern.test(specName);

View File

@@ -14,6 +14,6 @@ jasmineRequire.html = function(j$) {
j$.HtmlReporterV2Urls = jasmineRequire.HtmlReporterV2Urls(j$); j$.HtmlReporterV2Urls = jasmineRequire.HtmlReporterV2Urls(j$);
j$.HtmlReporterV2 = jasmineRequire.HtmlReporterV2(j$); j$.HtmlReporterV2 = jasmineRequire.HtmlReporterV2(j$);
j$.QueryString = jasmineRequire.QueryString(); j$.QueryString = jasmineRequire.QueryString();
j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter(); j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter(j$);
j$.private.HtmlSpecFilterV2 = jasmineRequire.HtmlSpecFilterV2(); j$.private.HtmlSpecFilterV2 = jasmineRequire.HtmlSpecFilterV2();
}; };