test(language-service): Update AppComponent test project to include more fields (#39033)

In preparation for the Ivy Language service, add the same properties to AppComponent that appear in
TemplateReference so the inline template can be tested thoroughly.

PR Close #39033
This commit is contained in:
Andrew Scott 2020-09-28 16:12:09 -07:00 committed by Alex Rickabaugh
parent 8f11b516f8
commit 8f66540152
2 changed files with 21 additions and 1 deletions

View File

@ -8,6 +8,7 @@
import {Component} from '@angular/core';
/** The most heroic being. */
export interface Hero {
id: number;
name: string;
@ -21,9 +22,27 @@ export interface Hero {
`
})
export class AppComponent {
/** This is the title of the `AppComponent` Component. */
title = 'Tour of Heroes';
hero: Hero = {id: 1, name: 'Windstorm'};
private internal: string = 'internal';
heroP = Promise.resolve(this.hero);
heroes: Hero[] = [this.hero];
heroesP = Promise.resolve(this.heroes);
tupleArray: [string, Hero] = ['test', this.hero];
league: Hero[][] = [this.heroes];
heroesByName: {[name: string]: Hero} = {};
primitiveIndexType: {[name: string]: string} = {};
anyValue: any;
optional?: string;
// Use to test the `index` variable conflict between the `ngFor` and component context.
index = null;
myClick(event: any) {}
birthday = new Date();
readonlyHeroes: ReadonlyArray<Readonly<Hero>> = this.heroes;
constNames = [{name: 'name'}] as const;
private myField = 'My Field';
strOrNumber: string|number = '';
setTitle(newTitle: string) {
this.title = newTitle;
}

View File

@ -134,7 +134,8 @@ export class MockTypescriptHost implements ts.LanguageServiceHost {
*/
overrideInlineTemplate(fileName: string, content: string): string {
const originalContent = this.getRawFileContent(fileName)!;
const newContent = originalContent.replace(/template: `([\s\S]+)`/, `template: \`${content}\``);
const newContent =
originalContent.replace(/template: `([\s\S]+?)`/, `template: \`${content}\``);
return this.override(fileName, newContent);
}