fix(DomSchemaRegistry): detect invalid elements
This commit is contained in:
@ -22,11 +22,12 @@ import {DEFAULT_INTERPOLATION_CONFIG, InterpolationConfig} from '../../src/ml_pa
|
||||
import {MockSchemaRegistry} from '../../testing/index';
|
||||
import {unparse} from '../expression_parser/unparser';
|
||||
|
||||
var someModuleUrl = 'package:someModule';
|
||||
const someModuleUrl = 'package:someModule';
|
||||
|
||||
var MOCK_SCHEMA_REGISTRY = [{
|
||||
const MOCK_SCHEMA_REGISTRY = [{
|
||||
provide: ElementSchemaRegistry,
|
||||
useValue: new MockSchemaRegistry({'invalidProp': false}, {'mappedAttr': 'mappedProp'})
|
||||
useValue: new MockSchemaRegistry(
|
||||
{'invalidProp': false}, {'mappedAttr': 'mappedProp'}, {'unknown': false, 'un-known': false}),
|
||||
}];
|
||||
|
||||
export function main() {
|
||||
@ -256,7 +257,7 @@ export function main() {
|
||||
});
|
||||
|
||||
describe('errors', () => {
|
||||
it('should throw error when binding to an unkonown property', () => {
|
||||
it('should throw error when binding to an unknown property', () => {
|
||||
expect(() => parse('<my-component [invalidProp]="bar"></my-component>', []))
|
||||
.toThrowError(`Template parse errors:
|
||||
Can't bind to 'invalidProp' since it isn't a known property of 'my-component'.
|
||||
@ -264,6 +265,20 @@ Can't bind to 'invalidProp' since it isn't a known property of 'my-component'.
|
||||
2. If 'my-component' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schema' of this component to suppress this message.
|
||||
("<my-component [ERROR ->][invalidProp]="bar"></my-component>"): TestComp@0:14`);
|
||||
});
|
||||
|
||||
it('should throw error when binding to an unknown element w/o bindings', () => {
|
||||
expect(() => parse('<unknown></unknown>', [])).toThrowError(`Template parse errors:
|
||||
'unknown' is not a known element:
|
||||
1. If 'unknown' is an Angular component, then verify that it is part of this module.
|
||||
2. If 'unknown' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schema' of this component to suppress this message. ("[ERROR ->]<unknown></unknown>"): TestComp@0:0`);
|
||||
});
|
||||
|
||||
it('should throw error when binding to an unknown custom element w/o bindings', () => {
|
||||
expect(() => parse('<un-known></un-known>', [])).toThrowError(`Template parse errors:
|
||||
'un-known' is not a known element:
|
||||
1. If 'un-known' is an Angular component, then verify that it is part of this module.
|
||||
2. If 'un-known' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schema' of this component to suppress this message. ("[ERROR ->]<un-known></un-known>"): TestComp@0:0`);
|
||||
});
|
||||
});
|
||||
|
||||
it('should parse bound properties via [...] and not report them as attributes', () => {
|
||||
|
Reference in New Issue
Block a user