diff --git a/packages/language-service/test/definitions_spec.ts b/packages/language-service/test/definitions_spec.ts index ba34e5254d0ca..b6849140bd92a 100644 --- a/packages/language-service/test/definitions_spec.ts +++ b/packages/language-service/test/definitions_spec.ts @@ -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}); + }); });