fix(DirectiveResolver): throw on duplicate Input & Output names
This commit is contained in:
@ -31,7 +31,6 @@ class SomeDirectiveWithOutputs {
|
||||
c: any;
|
||||
}
|
||||
|
||||
|
||||
@Directive({selector: 'someDirective', outputs: ['a']})
|
||||
class SomeDirectiveWithDuplicateOutputs {
|
||||
@Output() a: any;
|
||||
@ -43,6 +42,17 @@ class SomeDirectiveWithDuplicateRenamedOutputs {
|
||||
localA: any;
|
||||
}
|
||||
|
||||
@Directive({selector: 'someDirective', inputs: ['a']})
|
||||
class SomeDirectiveWithDuplicateInputs {
|
||||
@Input() a: any;
|
||||
}
|
||||
|
||||
@Directive({selector: 'someDirective', inputs: ['localA: a']})
|
||||
class SomeDirectiveWithDuplicateRenamedInputs {
|
||||
@Input() a: any;
|
||||
localA: any;
|
||||
}
|
||||
|
||||
@Directive({selector: 'someDirective'})
|
||||
class SomeDirectiveWithSetterProps {
|
||||
@Input('renamed')
|
||||
@ -133,6 +143,17 @@ export function main() {
|
||||
expect(directiveMetadata.inputs).toEqual(['a: renamed']);
|
||||
});
|
||||
|
||||
it('should throw if duplicate inputs', () => {
|
||||
expect(() => {
|
||||
resolver.resolve(SomeDirectiveWithDuplicateInputs);
|
||||
}).toThrowError(`Input 'a' defined multiple times in 'SomeDirectiveWithDuplicateInputs'`);
|
||||
});
|
||||
|
||||
it('should throw if duplicate inputs (with rename)', () => {
|
||||
expect(() => { resolver.resolve(SomeDirectiveWithDuplicateRenamedInputs); })
|
||||
.toThrowError(
|
||||
`Input 'a' defined multiple times in 'SomeDirectiveWithDuplicateRenamedInputs'`);
|
||||
});
|
||||
});
|
||||
|
||||
describe('outputs', () => {
|
||||
@ -151,6 +172,12 @@ export function main() {
|
||||
.toThrowError(
|
||||
`Output event 'a' defined multiple times in 'SomeDirectiveWithDuplicateOutputs'`);
|
||||
});
|
||||
|
||||
it('should throw if duplicate outputs (with rename)', () => {
|
||||
expect(() => { resolver.resolve(SomeDirectiveWithDuplicateRenamedOutputs); })
|
||||
.toThrowError(
|
||||
`Output event 'a' defined multiple times in 'SomeDirectiveWithDuplicateRenamedOutputs'`);
|
||||
});
|
||||
});
|
||||
|
||||
describe('host', () => {
|
||||
|
Reference in New Issue
Block a user