build(docs-infra): include directives etc in class descendants lists (#25768)
PR Close #25768
This commit is contained in:

committed by
Alex Rickabaugh

parent
ce06a75ebf
commit
15dadb92ef
@ -3,7 +3,12 @@ module.exports = function filterBy() {
|
||||
name: 'filterByPropertyValue',
|
||||
process: function(list, property, value) {
|
||||
if (!list) return list;
|
||||
return list.filter(item => item[property] === value);
|
||||
const values = Array.isArray(value) ? value : [value];
|
||||
return list.filter(item => values.some(value => compare(item[property], value)));
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
function compare(actual, expected) {
|
||||
return expected instanceof(RegExp) ? expected.test(actual) : actual === expected;
|
||||
}
|
@ -7,8 +7,19 @@ describe('filterByPropertyValue filter', () => {
|
||||
|
||||
it('should be called "filterByPropertyValue"', function() { expect(filter.name).toEqual('filterByPropertyValue'); });
|
||||
|
||||
it('should filter out items that do not match the given property value', function() {
|
||||
it('should filter out items that do not match the given property string value', function() {
|
||||
expect(filter.process([{ a: 1 }, { a: 2 }, { b: 1 }, { a: 1, b: 2 }, { a: null }, { a: undefined }], 'a', 1))
|
||||
.toEqual([{ a: 1 }, { a: 1, b: 2 }]);
|
||||
});
|
||||
|
||||
|
||||
it('should filter out items that do not match the given property regex value', function() {
|
||||
expect(filter.process([{ a: '1' }, { a: '12' }, { b: '1' }, { a: 'a' }, { a: '1', b: '2' }, { a: null }, { a: undefined }], 'a', /\d/))
|
||||
.toEqual([{ a: '1' }, { a: '12' }, { a: '1', b: '2' }]);
|
||||
});
|
||||
|
||||
it('should filter out items that do not match the given array of property regex/string values', function() {
|
||||
expect(filter.process([{ a: '1' }, { a: '12' }, { b: '1' }, { a: 'a' }, { a: '1', b: '2' }, { a: null }, { a: undefined }], 'a', [/\d/, 'a']))
|
||||
.toEqual([{ a: '1' }, { a: '12' }, { a: 'a' }, { a: '1', b: '2' }]);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user