Clicking a link in the HTML reporter does exact filtering
This feature requires an update to boot1.js, as shown in this commit. Users with an older boot1.js will get the older inexact filtering.
This commit is contained in:
38
src/html/HtmlExactSpecFilter.js
Normal file
38
src/html/HtmlExactSpecFilter.js
Normal file
@@ -0,0 +1,38 @@
|
||||
jasmineRequire.HtmlExactSpecFilter = function() {
|
||||
class HtmlExactSpecFilter {
|
||||
#getFilterString;
|
||||
|
||||
constructor(options) {
|
||||
if (typeof options?.filterString !== 'function') {
|
||||
throw new Error('options.filterString must be a function');
|
||||
}
|
||||
|
||||
this.#getFilterString = options.filterString;
|
||||
}
|
||||
|
||||
matches(spec) {
|
||||
const filterString = this.#getFilterString();
|
||||
|
||||
if (!filterString) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const filterPath = JSON.parse(this.#getFilterString());
|
||||
const specPath = spec.getPath();
|
||||
|
||||
if (filterPath.length > specPath.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let i = 0; i < filterPath.length; i++) {
|
||||
if (specPath[i] !== filterPath[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return HtmlExactSpecFilter;
|
||||
};
|
||||
Reference in New Issue
Block a user