Skip to content

Commit

Permalink
fix(language-service): re-add regressed templateUrl tests (angular#32438
Browse files Browse the repository at this point in the history
)

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

PR Close angular#32438
  • Loading branch information
ayazhafiz authored and mhevery committed Sep 3, 2019
1 parent a20fcbb commit 1ed3531
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/language-service/test/definitions_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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});
});
});

0 comments on commit 1ed3531

Please sign in to comment.