fix(language-service): re-add regressed templateUrl tests (#32438)

Commit 18ce58 (per #32378) regressed tests for templateUrl definitions.
This PR re-adds those tests.

PR Close #32438
This commit is contained in:
ayazhafiz 2019-09-01 09:58:14 -05:00 committed by Miško Hevery
parent a20fcbbe06
commit 1ed3531049
1 changed files with 22 additions and 0 deletions

View File

@ -253,4 +253,26 @@ describe('definitions', () => {
// Not asserting the textSpan of definition because it's external file
}
});
it('should be able to find a template from a url', () => {
const fileName = mockHost.addCode(`
@Component({
templateUrl: './«test».ng',
})
export class MyComponent {}`);
const marker = mockHost.getReferenceMarkerFor(fileName, 'test');
const result = ngService.getDefinitionAt(fileName, marker.start);
expect(result).toBeDefined();
const {textSpan, definitions} = result !;
expect(textSpan).toEqual({start: marker.start - 2, length: 9});
expect(definitions).toBeDefined();
expect(definitions !.length).toBe(1);
const [def] = definitions !;
expect(def.fileName).toBe('/app/test.ng');
expect(def.textSpan).toEqual({start: 0, length: 0});
});
});