From 05eabb19d624791c17cf447e8fea3a2ebee295ff Mon Sep 17 00:00:00 2001 From: Keen Yee Liau Date: Thu, 25 Apr 2019 10:50:19 -0700 Subject: [PATCH] test(language-service): Add external template (#30128) This is in preparation for more rigorous testing of external templates, since it'll work differently under the new tsserver plugin model. PR Close #30128 --- .../goldens/quickinfo_externalTemplate.json | 22 +++++++++++++++++++ .../project/app/app.component.ts | 2 +- .../project/app/app.module.ts | 3 ++- .../project/app/widget.component.html | 1 + .../project/app/widget.component.ts | 7 ++++++ integration/language_service_plugin/test.ts | 11 ++++++++++ 6 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 integration/language_service_plugin/goldens/quickinfo_externalTemplate.json create mode 100644 integration/language_service_plugin/project/app/widget.component.html create mode 100644 integration/language_service_plugin/project/app/widget.component.ts diff --git a/integration/language_service_plugin/goldens/quickinfo_externalTemplate.json b/integration/language_service_plugin/goldens/quickinfo_externalTemplate.json new file mode 100644 index 0000000000..ada1cae7cc --- /dev/null +++ b/integration/language_service_plugin/goldens/quickinfo_externalTemplate.json @@ -0,0 +1,22 @@ +{ + "seq": 0, + "type": "response", + "command": "quickinfo", + "request_seq": 4, + "success": true, + "body": { + "kind": "const", + "kindModifiers": "declare", + "start": { + "line": 1, + "offset": 17 + }, + "end": { + "line": 1, + "offset": 21 + }, + "displayString": "const name: never", + "documentation": "", + "tags": [] + } +} \ No newline at end of file diff --git a/integration/language_service_plugin/project/app/app.component.ts b/integration/language_service_plugin/project/app/app.component.ts index 7fb173cd01..26bd26cb4f 100644 --- a/integration/language_service_plugin/project/app/app.component.ts +++ b/integration/language_service_plugin/project/app/app.component.ts @@ -2,6 +2,6 @@ import { Component } from '@angular/core'; @Component({ selector: 'my-app', - template: `

Hello {{name}}

`, + template: `

Hello {{name}}

`, }) export class AppComponent { name = 'Angular'; } diff --git a/integration/language_service_plugin/project/app/app.module.ts b/integration/language_service_plugin/project/app/app.module.ts index 357b003a5a..7334238f7f 100644 --- a/integration/language_service_plugin/project/app/app.module.ts +++ b/integration/language_service_plugin/project/app/app.module.ts @@ -2,10 +2,11 @@ import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { AppComponent } from './app.component'; +import { WidgetComponent } from './widget.component'; @NgModule({ imports: [ BrowserModule ], - declarations: [ AppComponent ], + declarations: [ AppComponent, WidgetComponent ], bootstrap: [ AppComponent ] }) export class AppModule { } diff --git a/integration/language_service_plugin/project/app/widget.component.html b/integration/language_service_plugin/project/app/widget.component.html new file mode 100644 index 0000000000..a66ad1b63c --- /dev/null +++ b/integration/language_service_plugin/project/app/widget.component.html @@ -0,0 +1 @@ +

This is a {{name}} widget!

diff --git a/integration/language_service_plugin/project/app/widget.component.ts b/integration/language_service_plugin/project/app/widget.component.ts new file mode 100644 index 0000000000..293578176c --- /dev/null +++ b/integration/language_service_plugin/project/app/widget.component.ts @@ -0,0 +1,7 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'my-widget', + templateUrl: './widget.component.html', +}) +export class WidgetComponent { name = 'Angular'; } diff --git a/integration/language_service_plugin/test.ts b/integration/language_service_plugin/test.ts index b1b7cc498e..fb4f1c870c 100644 --- a/integration/language_service_plugin/test.ts +++ b/integration/language_service_plugin/test.ts @@ -118,6 +118,17 @@ describe('Angular Language Service', () => { offset: 28, }); expect(resp2).toMatchGolden('quickinfo.json'); + + client.sendRequest('open', { + file: `${PWD}/project/app/widget.component.html`, + }); + + const resp3 = await client.sendRequest('quickinfo', { + file: `${PWD}/project/app/widget.component.html`, + line: 1, + offset: 19, + }); + expect(resp3).toMatchGolden('quickinfo_externalTemplate.json'); }); it('should perform definition', async () => {