This repository has been archived by the owner on Sep 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
191 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
module.exports = class FilesFilter { | ||
filter() { | ||
throw new Error('Cannot call method of the base class'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use strict'; | ||
|
||
const FilesFilter = require('./files-filter'); | ||
|
||
module.exports = class IdentityFilter extends FilesFilter { | ||
filter(filesToFilter) { | ||
return filesToFilter; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict'; | ||
|
||
const _ = require('lodash'); | ||
|
||
const FilesFilter = require('./files-filter'); | ||
|
||
module.exports = class IntersectionFilter extends FilesFilter { | ||
constructor(files) { | ||
super(); | ||
|
||
this._files = files; | ||
} | ||
|
||
filter(filesToFilter) { | ||
return _.isEmpty(filesToFilter) | ||
? this._files | ||
: _.intersection(filesToFilter, this._files); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use strict'; | ||
|
||
const _ = require('lodash'); | ||
|
||
const IdentityFilter = require('./files-filter/identity-filter'); | ||
const IntersectionFilter = require('./files-filter/intersection-filter'); | ||
|
||
module.exports = class TestSet { | ||
static create(set) { | ||
return new TestSet(set); | ||
} | ||
|
||
constructor(set) { | ||
this._set = set; | ||
|
||
this._filesFilter = _.isEmpty(this._set.files) | ||
? new IdentityFilter() | ||
: new IntersectionFilter(this._set.files); | ||
} | ||
|
||
getFiles() { | ||
return this._set.files; | ||
} | ||
|
||
getBrowsers(path) { | ||
return _.includes(this._set.files, path) ? this._set.browsers : []; | ||
} | ||
|
||
filterFiles(files) { | ||
this._set.files = this._filesFilter.filter(files); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.