build(aio): improve enum
API rendering (#23872)
* The member details section is now called "Members", rather than "Properties". * The property table now displays appropriate table headings: "Member", "Value", "Description". * The "Value" column is not shown if none of the members have a value. Closes #22678 PR Close #23872
This commit is contained in:

committed by
Alex Rickabaugh

parent
a2e8b3a6a8
commit
02acb5e3e5
9
aio/tools/transforms/angular-base-package/rendering/hasValues.js
vendored
Normal file
9
aio/tools/transforms/angular-base-package/rendering/hasValues.js
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
module.exports = function hasValues() {
|
||||
return {
|
||||
name: 'hasValues',
|
||||
process: function(list, property) {
|
||||
if (!list || !Array.isArray(list)) return false;
|
||||
return list.some(item => item[property]);
|
||||
}
|
||||
};
|
||||
};
|
@ -0,0 +1,19 @@
|
||||
const factory = require('./hasValues');
|
||||
|
||||
describe('hasValues filter', () => {
|
||||
let filter;
|
||||
|
||||
beforeEach(function() { filter = factory(); });
|
||||
|
||||
it('should be called "hasValues"', function() { expect(filter.name).toEqual('hasValues'); });
|
||||
|
||||
it('should return true if the specified property is truthy on any item in the list', function() {
|
||||
expect(filter.process([], 'a')).toEqual(false);
|
||||
expect(filter.process(0), 'a').toEqual(false);
|
||||
expect(filter.process({}, 'a')).toEqual(false);
|
||||
expect(filter.process([{a: 1}], 'a')).toEqual(true);
|
||||
expect(filter.process([{b: 2}], 'a')).toEqual(false);
|
||||
expect(filter.process([{a: 1, b: 2}], 'a')).toEqual(true);
|
||||
expect(filter.process([{b: 2}, {a: 1}], 'a')).toEqual(true);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user