fix(compiler): improve the error when template is not a string

Closes #8708
Closes #13377
This commit is contained in:
Dzmitry Shylovich
2016-12-11 13:49:03 +03:00
committed by Hans Larsen
parent 5b4bea24de
commit 2c0c86e3ce
2 changed files with 26 additions and 2 deletions

View File

@ -33,6 +33,22 @@ export function main() {
moduleUrl: SOME_MODULE_URL,
})).toThrowError(SyntaxError, 'No template specified for component SomeComp');
}));
it('should throw if template is not a string',
inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
expect(
() => normalizer.normalizeTemplate(
{componentType: SomeComp, moduleUrl: SOME_MODULE_URL, template: <any>{}}))
.toThrowError(
SyntaxError, 'The template specified for component SomeComp is not a string');
}));
it('should throw if templateUrl is not a string',
inject([DirectiveNormalizer], (normalizer: DirectiveNormalizer) => {
expect(
() => normalizer.normalizeTemplate(
{componentType: SomeComp, moduleUrl: SOME_MODULE_URL, templateUrl: <any>{}}))
.toThrowError(
SyntaxError, 'The templateUrl specified for component SomeComp is not a string');
}));
});
describe('normalizeTemplateSync', () => {
@ -535,4 +551,4 @@ function programResourceLoaderSpy(spy: SpyResourceLoader, results: {[key: string
});
}
class SomeComp {}
class SomeComp {}