Skip to content

Commit e0505dd

Browse files
committedOct 12, 2021
Runtime deprecation warnings for methods that will be removed in 4.0
1 parent 68a6e7b commit e0505dd

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed
 

‎lib/jasmine.js

+14-5
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ Jasmine.prototype.loadConfig = function(config) {
336336
* @type string[] | undefined
337337
*/
338338
if(config.helpers) {
339-
this.addHelperFiles(config.helpers);
339+
this.addMatchingHelperFiles(config.helpers);
340340
}
341341

342342
/**
@@ -356,7 +356,7 @@ Jasmine.prototype.loadConfig = function(config) {
356356
* @type string[] | undefined
357357
*/
358358
if(config.spec_files) {
359-
this.addSpecFiles(config.spec_files);
359+
this.addMatchingSpecFiles(config.spec_files);
360360
}
361361
};
362362

@@ -392,7 +392,12 @@ Jasmine.prototype.addMatchingHelperFiles = addFiles('helperFiles');
392392
* {@link Jasmine#loadConfig|loadConfig}, or {@link Jasmine#loadConfigFile|loadConfigFile}
393393
* instead.
394394
*/
395-
Jasmine.prototype.addSpecFiles = Jasmine.prototype.addMatchingSpecFiles;
395+
Jasmine.prototype.addSpecFiles = function(globs) {
396+
this.env.deprecated('jasmine#addSpecFiles is deprecated. Use ' +
397+
'jasmine#addMatchingSpecFiles instead.');
398+
this.addMatchingSpecFiles(globs);
399+
};
400+
396401
/**
397402
* Synonym for {@link Jasmine#addMatchingHelperFiles}
398403
* @name Jasmine#addHelperFiles
@@ -401,7 +406,11 @@ Jasmine.prototype.addSpecFiles = Jasmine.prototype.addMatchingSpecFiles;
401406
* {@link Jasmine#loadConfig|loadConfig}, or {@link Jasmine#loadConfigFile|loadConfigFile}
402407
* instead.
403408
*/
404-
Jasmine.prototype.addHelperFiles = Jasmine.prototype.addMatchingHelperFiles;
409+
Jasmine.prototype.addHelperFiles = function(globs) {
410+
this.env.deprecated('jasmine#addHelperFiles is deprecated. Use ' +
411+
'jasmine#addMatchingHelperFiles instead.');
412+
this.addMatchingHelperFiles(globs);
413+
};
405414

406415
Jasmine.prototype.addRequires = function(requires) {
407416
const jasmineRunner = this;
@@ -569,7 +578,7 @@ Jasmine.prototype.execute = async function(files, filterString) {
569578
if (files && files.length > 0) {
570579
this.specDir = '';
571580
this.specFiles = [];
572-
this.addSpecFiles(files);
581+
this.addMatchingSpecFiles(files);
573582
}
574583

575584
await this.loadSpecs();

‎spec/jasmine_spec.js

+24
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,39 @@ describe('Jasmine', function() {
5656

5757
describe('Methods that specify files via globs', function() {
5858
describe('#addSpecFiles', function() {
59+
beforeEach(function() {
60+
this.testJasmine.env.deprecated = jasmine.createSpy('env.deprecated');
61+
});
62+
5963
hasCommonFileGlobBehavior('addSpecFiles', 'specFiles');
64+
65+
it('issues a deprecation warning', function() {
66+
this.testJasmine.addSpecFiles([]);
67+
expect(this.testJasmine.env.deprecated).toHaveBeenCalledWith(
68+
'jasmine#addSpecFiles is deprecated. Use ' +
69+
'jasmine#addMatchingSpecFiles instead.'
70+
);
71+
});
6072
});
6173

6274
describe('#addMatchingSpecFiles', function() {
6375
hasCommonFileGlobBehavior('addMatchingSpecFiles', 'specFiles');
6476
});
6577

6678
describe('#addHelperFiles', function() {
79+
beforeEach(function() {
80+
this.testJasmine.env.deprecated = jasmine.createSpy('env.deprecated');
81+
});
82+
6783
hasCommonFileGlobBehavior('addHelperFiles', 'helperFiles');
84+
85+
it('issues a deprecation warning', function() {
86+
this.testJasmine.addHelperFiles([]);
87+
expect(this.testJasmine.env.deprecated).toHaveBeenCalledWith(
88+
'jasmine#addHelperFiles is deprecated. Use ' +
89+
'jasmine#addMatchingHelperFiles instead.'
90+
);
91+
});
6892
});
6993

7094
describe('#addMatchingHelperFiles', function() {

0 commit comments

Comments
 (0)
Please sign in to comment.