build(aio): ensure the correct decorator properties are merged (#24289)
Previously only the `description` and `usageNotes` were being copied over from the call-member of the decorator interface. Important properties such as `shortDescription` were missed. These are now added and the code has been refactored to make it simpler and clearer to update which properties get copied as the requirements change. PR Close #24289
This commit is contained in:

committed by
Victor Berchet

parent
acf270d724
commit
68d37ef0c1
@ -1,4 +1,4 @@
|
||||
const { mapObject, parseAttributes, renderAttributes } = require('./utils');
|
||||
const { mergeProperties, mapObject, parseAttributes, renderAttributes } = require('./utils');
|
||||
|
||||
describe('utils', () => {
|
||||
describe('mapObject', () => {
|
||||
@ -96,4 +96,34 @@ describe('utils', () => {
|
||||
expect(renderAttributes({ })).toEqual('');
|
||||
});
|
||||
});
|
||||
|
||||
describe('mergeProperties', () => {
|
||||
it('should write specified properties from the source to the target', () => {
|
||||
const source = { a: 1, b: 2, c: 3 };
|
||||
const target = { };
|
||||
mergeProperties(target, source, ['a', 'b']);
|
||||
expect(target).toEqual({ a: 1, b: 2 });
|
||||
});
|
||||
|
||||
it('should not overwrite target properties that are not specified', () => {
|
||||
const source = { a: 1, b: 2, c: 3 };
|
||||
const target = { b: 10 };
|
||||
mergeProperties(target, source, ['a']);
|
||||
expect(target).toEqual({ a: 1, b: 10 });
|
||||
});
|
||||
|
||||
it('should not overwrite target properties that are specified but do not exist in the source', () => {
|
||||
const source = { a: 1 };
|
||||
const target = { b: 10 };
|
||||
mergeProperties(target, source, ['a', 'b']);
|
||||
expect(target).toEqual({ a: 1, b: 10 });
|
||||
});
|
||||
|
||||
it('should overwrite target properties even if they are `undefined` in the source', () => {
|
||||
const source = { a: undefined };
|
||||
const target = { a: 10 };
|
||||
mergeProperties(target, source, ['a']);
|
||||
expect(target).toEqual({ a: undefined });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user