test(compiler-cli): fix tests to have at least one component (#39011)

With the introduction of incremental type checking in #36211, an
intermediate `ts.Program` for type checking is only created if there are
any templates to check. This rendered some tests ineffective at avoiding
regressions, as the intermediate `ts.Program` was required for the tests
to fail if the scenario under test would not be accounted for. This
commit adds a single component to these tests, to ensure the
intermediate `ts.Program` is in fact created.

PR Close #39011
This commit is contained in:
JoostK 2020-09-26 22:28:12 +02:00 committed by Alex Rickabaugh
parent e9a8f9f705
commit 06525cfed3
1 changed files with 11 additions and 2 deletions

View File

@ -433,8 +433,13 @@ runInEachFileSystem(() => {
});
it('should compile incrementally with template type-checking turned on', () => {
env.tsconfig({ivyTemplateTypeCheck: true});
env.write('main.ts', 'export class Foo {}');
env.tsconfig({fullTemplateTypeCheck: true});
env.write('main.ts', `
import {Component} from '@angular/core';
@Component({template: ''})
export class MyComponent {}
`);
env.driveMain();
env.invalidateCachedFile('main.ts');
env.driveMain();
@ -482,8 +487,12 @@ runInEachFileSystem(() => {
env.write('node_modules/b/index.js', `export {ServiceA as ServiceB} from 'a';`);
env.write('node_modules/b/index.d.ts', `export {ServiceA as ServiceB} from 'a';`);
env.write('test.ts', `
import {Component} from '@angular/core';
import {ServiceA} from 'a';
import {ServiceB} from 'b';
@Component({template: ''})
export class MyComponent {}
`);
env.driveMain();
env.flushWrittenFileTracking();