Skip to content
This repository was archived by the owner on Sep 21, 2022. It is now read-only.

Commit 60c1147

Browse files
committed
fix: enable correct suite through suite collection api
If there are 2 suites with equal names suiteCollection.enable will enable first suite
1 parent 3377412 commit 60c1147

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

lib/suite-collection.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,14 @@ module.exports = class SuiteCollection {
106106
}
107107

108108
_disableEntity(obj, browser) {
109-
this._originalBrowsers[obj.fullName] = obj.browsers;
109+
this._originalBrowsers[obj.fullName + obj.file] = obj.browsers;
110110
obj.browsers = browser ? _.without(obj.browsers, browser) : [];
111111
}
112112

113113
_enableEntity(obj, browser) {
114-
if (!browser && this._originalBrowsers[obj.fullName]) {
115-
obj.browsers = _.union(obj.browsers, this._originalBrowsers[obj.fullName]);
114+
const suiteKey = obj.fullName + obj.file;
115+
if (!browser && this._originalBrowsers[suiteKey]) {
116+
obj.browsers = _.union(obj.browsers, this._originalBrowsers[suiteKey]);
116117
}
117118

118119
if (browser) {

test/unit/suite-collection.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const proxyquire = require('proxyquire');
44
const mkTree = require('../util').makeSuiteTree;
5+
const mkSuite = require('../util').makeSuiteStub;
56

67
describe('suite-collection', () => {
78
const sandbox = sinon.sandbox.create();
@@ -385,6 +386,26 @@ describe('suite-collection', () => {
385386
assert.deepEqual(tree.child.browsers, ['b1', 'b2']);
386387
});
387388

389+
it('should enable only current suite if there are the same suites exists in the tree', () => {
390+
const suite1 = mkSuite({
391+
name: 'suite',
392+
browsers: ['b1', 'b2'],
393+
file: 'some/path.js'
394+
});
395+
const suite2 = mkSuite({
396+
name: 'suite',
397+
browsers: ['b3', 'b4'],
398+
file: 'another/path.js'
399+
});
400+
401+
new SuiteCollection([suite1, suite2])
402+
.disableAll()
403+
.enable(suite1);
404+
405+
assert.deepEqual(suite1.browsers, ['b1', 'b2']);
406+
assert.deepEqual(suite2.browsers, []);
407+
});
408+
388409
it('should fail on attempt to enable unknown suite', () => {
389410
const tree = mkTree({
390411
suite: []

test/util.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ function makeSuiteStub(opts) {
4747
suite.addState(state);
4848
});
4949
suite.url = opts.url;
50+
suite.file = opts.file;
5051

5152
return suite;
5253
}

0 commit comments

Comments
 (0)