Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cb8e51f

Browse filesBrowse files
danieltre23alxhub
authored andcommitted
test(language-service): add extended diagnostics test (#43107)
Add a test in the langauge-service to make sure the extended template diagnostics are being correctly generated. Refs #42966 PR Close #43107
1 parent e6b2bed commit cb8e51f
Copy full SHA for cb8e51f

File tree

Expand file treeCollapse file tree

2 files changed

+44
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+44
-2
lines changed

‎packages/language-service/ivy/test/diagnostic_spec.ts

Copy file name to clipboardExpand all lines: packages/language-service/ivy/test/diagnostic_spec.ts
+41Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,47 @@ describe('getSemanticDiagnostics', () => {
361361
expect(diag.category).toBe(ts.DiagnosticCategory.Error);
362362
expect(getTextOfDiagnostic(diag)).toBe(`'./missing.css'`);
363363
});
364+
365+
it('should produce invalid banana in box warning', () => {
366+
const files = {
367+
'app.ts': `
368+
import {Component} from '@angular/core';
369+
@Component({
370+
selector: 'test',
371+
template: '<div ([notARealThing])="bar"></div>',
372+
})
373+
export class TestCmp {
374+
bar: string = "text";
375+
}
376+
`
377+
};
378+
const project = createModuleAndProjectWithDeclarations(
379+
env, 'test', files, {strictTemplates: true, _extendedTemplateDiagnostics: true});
380+
381+
const diags = project.getDiagnosticsForFile('app.ts');
382+
expect(diags.length).toEqual(1);
383+
expect(diags[0].code).toEqual(ErrorCode.INVALID_BANANA_IN_BOX);
384+
expect(diags[0].category).toEqual(ts.DiagnosticCategory.Warning);
385+
});
386+
387+
it('should not produce invalid banana in box warning', () => {
388+
const files = {
389+
'app.ts': `
390+
import {Component} from '@angular/core';
391+
@Component({
392+
selector: 'test',
393+
template: '<div ([notARealThing])="bar"></div>',
394+
})
395+
export class TestCmp {
396+
bar: string = "text";
397+
}
398+
`
399+
};
400+
const project = createModuleAndProjectWithDeclarations(env, 'test', files);
401+
402+
const diags = project.getDiagnosticsForFile('app.ts');
403+
expect(diags.length).toEqual(0);
404+
});
364405
});
365406

366407
function getTextOfDiagnostic(diag: ts.Diagnostic): string {

‎packages/language-service/ivy/testing/src/project.ts

Copy file name to clipboardExpand all lines: packages/language-service/ivy/testing/src/project.ts
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {LegacyNgcOptions, StrictTemplateOptions} from '@angular/compiler-cli/src/ngtsc/core/api';
9+
import {InternalOptions, LegacyNgcOptions, StrictTemplateOptions} from '@angular/compiler-cli/src/ngtsc/core/api';
1010
import {absoluteFrom, AbsoluteFsPath, FileSystem, getFileSystem, getSourceFileOrError} from '@angular/compiler-cli/src/ngtsc/file_system';
1111
import {OptimizeFor, TemplateTypeChecker} from '@angular/compiler-cli/src/ngtsc/typecheck/api';
1212
import * as ts from 'typescript/lib/tsserverlibrary';
@@ -44,7 +44,8 @@ function writeTsconfig(
4444
null, 2));
4545
}
4646

47-
export type TestableOptions = StrictTemplateOptions&Pick<LegacyNgcOptions, 'fullTemplateTypeCheck'>;
47+
export type TestableOptions =
48+
StrictTemplateOptions&InternalOptions&Pick<LegacyNgcOptions, 'fullTemplateTypeCheck'>;
4849

4950
export class Project {
5051
private tsProject: ts.server.Project;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.