message: test(language-service): Completions test should reuse existing host and services
  Reusing the single instance of MockHost and language services makes the
  tests run much faster.
  PR Close
diff: import * as ts from 'typescript';
  import {createLanguageService} from '../src/language_service';
  -import {CompletionKind, LanguageService} from '../src/types';
  +import {CompletionKind} from '../src/types';
  import {TypeScriptServiceHost} from '../src/typescript_host';
  import {MockTypescriptHost} from './test_utils';
  @@ -25,6 +25,8 @@ describe('completions', () => {
  const ngHost = new TypeScriptServiceHost(mockHost, tsLS);
  const ngLS = createLanguageService(ngHost);
  + beforeEach(() => { mockHost.reset(); });
  +
  it('should be able to get entity completions', () => {
  const marker = mockHost.getLocationMarkerFor(APP_COMPONENT, 'entity-amp');
  const completions = ngLS.getCompletionsAt(APP_COMPONENT, marker.start);
  @@ -370,19 +372,8 @@ describe('completions', () => {
  // expectContain(completions, CompletionKind.PROPERTY, ['innerText']);
  // });
  });
  -});
  -
  -describe('replace completions correctly', () => {
  - const mockHost = new MockTypescriptHost(['/app/main.ts']);
  - let ngLS: LanguageService;
  -
  - beforeEach(() => {
  - mockHost.reset();
  - const tsLS = ts.createLanguageService(mockHost);
  - const ngHost = new TypeScriptServiceHost(mockHost, tsLS);
  - ngLS = createLanguageService(ngHost);
  - });
  + describe('replacement span', () => {
  it('should not generate replacement entries for zero-length replacements', () => {
  const fileName = mockHost.addCode(`
  @Component({
  @@ -558,6 +549,7 @@ describe('replace completions correctly', () => {
  expect(completion.replacementSpan).toEqual({start: location.start - 5, length: 5});
  });
  });
  +});
  function expectContain(
  completions: ts.CompletionInfo | undefined, kind: CompletionKind, names: string[]) {
  