test(language-service): Add tests for quickinfo and definition (#29990)

`quickinfo` is used for hover tooltip.
`definition` is used for "Go to definition".

PR Close #29990
This commit is contained in:
Keen Yee Liau
2019-04-19 08:53:19 -07:00
committed by Ben Lesh
parent f348deae92
commit 017bf0b794
7 changed files with 127 additions and 40 deletions

View File

@ -50,7 +50,6 @@ describe('Angular Language Service', () => {
// https://github.com/Microsoft/TypeScript/blob/master/lib/protocol.d.ts#L1055
client.sendRequest('open', {
file: `${PWD}/project/app/app.module.ts`,
fileContent: ""
});
// Server does not send response to geterr request
// https://github.com/Microsoft/TypeScript/blob/master/lib/protocol.d.ts#L1770
@ -77,7 +76,6 @@ describe('Angular Language Service', () => {
client.sendRequest('open', {
file: `${PWD}/project/app/app.component.ts`,
fileContent: "import { Component } from '@angular/core';\n\n@Component({\n selector: 'my-app',\n template: `<h1>Hello {{name}}</h1>`,\n})\nexport class AppComponent { name = 'Angular'; }\n"
});
client.sendRequest('geterr', {
@ -101,4 +99,44 @@ describe('Angular Language Service', () => {
});
expect(response).toMatchGolden('completionInfo.json');
});
it('should perform quickinfo', async () => {
client.sendRequest('open', {
file: `${PWD}/project/app/app.component.ts`,
});
const resp1 = await client.sendRequest('reload', {
file: `${PWD}/project/app/app.component.ts`,
tmpFile: `${PWD}/project/app/app.component.ts`,
}) as any;
expect(resp1.command).toBe('reload');
expect(resp1.success).toBe(true);
const resp2 = await client.sendRequest('quickinfo', {
file: `${PWD}/project/app/app.component.ts`,
line: 5,
offset: 28,
});
expect(resp2).toMatchGolden('quickinfo.json');
});
it('should perform definition', async () => {
client.sendRequest('open', {
file: `${PWD}/project/app/app.component.ts`,
});
const resp1 = await client.sendRequest('reload', {
file: `${PWD}/project/app/app.component.ts`,
tmpFile: `${PWD}/project/app/app.component.ts`,
}) as any;
expect(resp1.command).toBe('reload');
expect(resp1.success).toBe(true);
const resp2 = await client.sendRequest('definition', {
file: `${PWD}/project/app/app.component.ts`,
line: 5,
offset: 28,
});
expect(resp2).toMatchGolden('definition.json');
});
});