feat(compiler): assert that Component.style is an array
Part of #7481 (effort to improve error messages) Closes #7559
This commit is contained in:
@ -0,0 +1,9 @@
|
||||
library angular2.test.compiler.runtime_metadata_fixture;
|
||||
|
||||
import "package:angular2/core.dart" show Component;
|
||||
|
||||
// This component is not actually malformed; this fixture is here to
|
||||
// make Dart not complain about a missing import for a test case that only
|
||||
// matters in an JavaScript app.
|
||||
@Component(template: "")
|
||||
class MalformedStylesComponent {}
|
@ -0,0 +1,5 @@
|
||||
import {Component} from 'angular2/core';
|
||||
|
||||
@Component({styles:<any>('foo'), template: ''})
|
||||
export class MalformedStylesComponent {
|
||||
}
|
@ -37,6 +37,7 @@ import {TEST_PROVIDERS} from './test_bindings';
|
||||
import {MODULE_SUFFIX} from 'angular2/src/compiler/util';
|
||||
import {IS_DART} from 'angular2/src/facade/lang';
|
||||
import {PLATFORM_DIRECTIVES} from 'angular2/src/core/platform_directives_and_pipes';
|
||||
import {MalformedStylesComponent} from './runtime_metadata_fixture';
|
||||
|
||||
export function main() {
|
||||
describe('RuntimeMetadataResolver', () => {
|
||||
@ -74,6 +75,14 @@ export function main() {
|
||||
var expectedEndValue = IS_DART ? 'test/compiler/runtime_metadata_spec.dart' : './';
|
||||
expect(value.endsWith(expectedEndValue)).toBe(true);
|
||||
}));
|
||||
|
||||
it('should throw when metadata is incorrectly typed',
|
||||
inject([RuntimeMetadataResolver], (resolver: RuntimeMetadataResolver) => {
|
||||
if (!IS_DART) {
|
||||
expect(() => resolver.getDirectiveMetadata(MalformedStylesComponent))
|
||||
.toThrowError(`Expected 'styles' to be an array of strings.`);
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
describe('getViewDirectivesMetadata', () => {
|
||||
|
Reference in New Issue
Block a user