Re-add support for partial spec name filtering
No UI for this but users can construct URLs manually. Fixes #2085.
This commit is contained in:
@@ -1,48 +1,69 @@
|
||||
describe('HtmlSpecFilterV2', function() {
|
||||
it('matches everything when no string is provided', function() {
|
||||
const specFilter = new privateUnderTest.HtmlSpecFilterV2({
|
||||
filterString() {
|
||||
return '';
|
||||
}
|
||||
});
|
||||
describe('When both query parameters are falsy', function() {
|
||||
it('matches everything', function() {
|
||||
const specFilter = new privateUnderTest.HtmlSpecFilterV2({
|
||||
filterParams() {
|
||||
return { path: '', spec: '' };
|
||||
}
|
||||
});
|
||||
|
||||
expect(specFilter.matches({})).toBeTrue();
|
||||
expect(specFilter.matches({})).toBeTrue();
|
||||
});
|
||||
});
|
||||
|
||||
it('matches a spec with the exact same path', function() {
|
||||
const specFilter = new privateUnderTest.HtmlSpecFilterV2({
|
||||
filterString() {
|
||||
return '["a","b","c"]';
|
||||
}
|
||||
describe('When the path parameter is truthy', function() {
|
||||
it('matches a spec with the exact same path', function() {
|
||||
const specFilter = new privateUnderTest.HtmlSpecFilterV2({
|
||||
filterParams() {
|
||||
return { path: '["a","b","c"]', spec: '' };
|
||||
}
|
||||
});
|
||||
|
||||
expect(specFilter.matches(stubSpec(['a', 'b', 'c']))).toBeTrue();
|
||||
});
|
||||
|
||||
expect(specFilter.matches(stubSpec(['a', 'b', 'c']))).toBeTrue();
|
||||
});
|
||||
it('matches a spec whose path has the filter path as a prefix', function() {
|
||||
const specFilter = new privateUnderTest.HtmlSpecFilterV2({
|
||||
filterParams() {
|
||||
return { path: '["a","b"]', spec: '' };
|
||||
}
|
||||
});
|
||||
|
||||
it('matches a spec whose path has the filter path as a prefix', function() {
|
||||
const specFilter = new privateUnderTest.HtmlSpecFilterV2({
|
||||
filterString() {
|
||||
return '["a","b"]';
|
||||
}
|
||||
expect(specFilter.matches(stubSpec(['a', 'b', 'c']))).toBeTrue();
|
||||
});
|
||||
|
||||
expect(specFilter.matches(stubSpec(['a', 'b', 'c']))).toBeTrue();
|
||||
});
|
||||
it('does not match a spec with a different path', function() {
|
||||
const specFilter = new privateUnderTest.HtmlSpecFilterV2({
|
||||
filterParams() {
|
||||
return { path: '["a","b","c"]', spec: '' };
|
||||
}
|
||||
});
|
||||
|
||||
it('does not match a spec with a different path', function() {
|
||||
const specFilter = new privateUnderTest.HtmlSpecFilterV2({
|
||||
filterString() {
|
||||
return '["a","b","c"]';
|
||||
}
|
||||
expect(specFilter.matches(stubSpec(['a', 'd', 'c']))).toBeFalse();
|
||||
});
|
||||
|
||||
expect(specFilter.matches(stubSpec(['a', 'd', 'c']))).toBeFalse();
|
||||
});
|
||||
|
||||
function stubSpec(path) {
|
||||
describe('When the path parameter is falsy and the spec parameter is truthy', function() {
|
||||
it('matches specs with full names containing the parameter value', function() {
|
||||
const specFilter = new privateUnderTest.HtmlSpecFilterV2({
|
||||
filterParams() {
|
||||
return { path: '', spec: 'bar' };
|
||||
}
|
||||
});
|
||||
|
||||
expect(specFilter.matches(stubSpec('', 'foo bar baz'))).toBeTrue();
|
||||
expect(specFilter.matches(stubSpec('', 'foo baz'))).toBeFalse();
|
||||
expect(specFilter.matches(stubSpec('', 'sandbars'))).toBeTrue();
|
||||
});
|
||||
});
|
||||
|
||||
function stubSpec(path, fullName) {
|
||||
return {
|
||||
getPath() {
|
||||
return path;
|
||||
},
|
||||
getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user