fix(compiler): narrow the span reported for invalid pipes

fixes #13326
closes #13411
This commit is contained in:
Chuck Jazdzewski
2016-12-12 15:59:12 -08:00
committed by Victor Berchet
parent 3a64ad895a
commit 2b90cd532f
5 changed files with 54 additions and 6 deletions

View File

@ -151,6 +151,18 @@ describe('diagnostics', () => {
});
});
// Issue #13326
it('should report a narrow span for invalid pipes', () => {
const code =
` @Component({template: '<p> Using an invalid pipe {{data | dat}} </p>'}) export class MyComponent { data = 'some data'; }`;
addCode(code, fileName => {
const diagnostic =
ngService.getDiagnostics(fileName).filter(d => d.message.indexOf('pipe') > 0)[0];
expect(diagnostic).not.toBeUndefined();
expect(diagnostic.span.end - diagnostic.span.start).toBeLessThan(11);
});
});
function addCode(code: string, cb: (fileName: string, content?: string) => void) {
const fileName = '/app/app.component.ts';
const originalContent = mockHost.getFileContent(fileName);