fix(language-service): avoid throwing exceptions when reporting metadata errors
This commit is contained in:

committed by
Alex Rickabaugh

parent
c6917d9d4f
commit
7764c5c697
@ -201,6 +201,25 @@ describe('diagnostics', () => {
|
||||
expect(diagnostic).toEqual([]);
|
||||
});
|
||||
|
||||
|
||||
it('should report an error for invalid providers', () => {
|
||||
addCode(
|
||||
`
|
||||
@Component({
|
||||
template: '',
|
||||
providers: [null]
|
||||
})
|
||||
export class MyComponent {}
|
||||
`,
|
||||
fileName => {
|
||||
const diagnostics = ngService.getDiagnostics(fileName);
|
||||
const expected = diagnostics.find(d => d.message.startsWith('Invalid providers for'));
|
||||
const notExpected = diagnostics.find(d => d.message.startsWith('Cannot read property'));
|
||||
expect(expected).toBeDefined();
|
||||
expect(notExpected).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
function addCode(code: string, cb: (fileName: string, content?: string) => void) {
|
||||
const fileName = '/app/app.component.ts';
|
||||
const originalContent = mockHost.getFileContent(fileName);
|
||||
|
Reference in New Issue
Block a user