/** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import 'reflect-metadata'; import * as ts from 'typescript'; import {createLanguageService} from '../src/language_service'; import {Hover} from '../src/types'; import {TypeScriptServiceHost} from '../src/typescript_host'; import {toh} from './test_data'; import {MockTypescriptHost} from './test_utils'; describe('hover', () => { let documentRegistry = ts.createDocumentRegistry(); let mockHost = new MockTypescriptHost(['/app/main.ts', '/app/parsing-cases.ts'], toh); let service = ts.createLanguageService(mockHost, documentRegistry); let ngHost = new TypeScriptServiceHost(mockHost, service); let ngService = createLanguageService(ngHost); it('should be able to find field in an interpolation', () => { hover( ` @Component({template: '{{«name»}}'}) export class MyComponent { name: string; }`, 'property name of MyComponent'); }); it('should be able to find a field in a attribute reference', () => { hover( ` @Component({template: ''}) export class MyComponent { name: string; }`, 'property name of MyComponent'); }); it('should be able to find a method from a call', () => { hover( ` @Component({template: '
'}) export class MyComponent { myClick() { }}`, 'method myClick of MyComponent'); }); it('should be able to find a field reference in an *ngIf', () => { hover( ` @Component({template: ''}) export class MyComponent { include = true;}`, 'property include of MyComponent'); }); it('should be able to find a reference to a component', () => { hover( ` @Component({template: '«<ᐱtestᐱ-comp>»'}) export class MyComponent { }`, 'component TestComponent'); }); it('should be able to find an event provider', () => { hover( ` @Component({template: '