From 8f665401526f2b1aac0d372ce49b82c861dad662 Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Mon, 28 Sep 2020 16:12:09 -0700 Subject: [PATCH] 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 --- .../test/project/app/app.component.ts | 19 +++++++++++++++++++ packages/language-service/test/test_utils.ts | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/language-service/test/project/app/app.component.ts b/packages/language-service/test/project/app/app.component.ts index e1ac8cd409..ccf6a9c1f0 100644 --- a/packages/language-service/test/project/app/app.component.ts +++ b/packages/language-service/test/project/app/app.component.ts @@ -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> = this.heroes; + constNames = [{name: 'name'}] as const; + private myField = 'My Field'; + strOrNumber: string|number = ''; setTitle(newTitle: string) { this.title = newTitle; } diff --git a/packages/language-service/test/test_utils.ts b/packages/language-service/test/test_utils.ts index ee3c3d7eee..0be4ff12cf 100644 --- a/packages/language-service/test/test_utils.ts +++ b/packages/language-service/test/test_utils.ts @@ -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); }