From 23360d1215d86e531ece8181ca2d3bde7451de5f Mon Sep 17 00:00:00 2001 From: Alex Rickabaugh Date: Tue, 2 Feb 2021 14:20:40 -0800 Subject: [PATCH] test(language-service): update compiler_spec to use the new testing env (#40966) This commit updates compiler_spec.ts in the Ivy LS suite to utilize the new testing environment which was introduced in the previous commit. Eventually all specs should be converted, but converting one right now helps ensure that the new testing env is working properly and able to support real tests. PR Close #40966 --- .../ivy/test/compiler_spec.ts | 34 ++++++------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/packages/language-service/ivy/test/compiler_spec.ts b/packages/language-service/ivy/test/compiler_spec.ts index 4838441e0c..027c32ff3a 100644 --- a/packages/language-service/ivy/test/compiler_spec.ts +++ b/packages/language-service/ivy/test/compiler_spec.ts @@ -6,11 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import {absoluteFrom} from '@angular/compiler-cli/src/ngtsc/file_system'; import {initMockFileSystem} from '@angular/compiler-cli/src/ngtsc/file_system/testing'; import {isNgSpecificDiagnostic, LanguageServiceTestEnv} from '../testing'; -import {LanguageServiceTestEnvironment} from './env'; describe('language-service/compiler integration', () => { beforeEach(() => { @@ -18,35 +16,25 @@ describe('language-service/compiler integration', () => { }); it('should react to a change in an external template', () => { - const cmpFile = absoluteFrom('/test.ts'); - const tmplFile = absoluteFrom('/test.html'); - - const env = LanguageServiceTestEnvironment.setup([ - { - name: cmpFile, - contents: ` - import {Component} from '@angular/core'; + const env = LanguageServiceTestEnv.setup(); + const project = env.addProject('test', { + 'test.ts': ` + import {Component} from '@angular/core'; @Component({ selector: 'test-cmp', templateUrl: './test.html', }) export class TestCmp {} - `, - isRoot: true, - }, - { - name: tmplFile, - contents: 'Test', - }, - ]); + `, + 'test.html': `Test` + }); - const diags = env.ngLS.getSemanticDiagnostics(cmpFile); - expect(diags.length).toBeGreaterThan(0); + expect(project.getDiagnosticsForFile('test.ts').length).toBeGreaterThan(0); - env.updateFile(tmplFile, '
Test
'); - const afterDiags = env.ngLS.getSemanticDiagnostics(cmpFile); - expect(afterDiags.length).toBe(0); + const tmplFile = project.openFile('test.html'); + tmplFile.contents = '
Test
'; + expect(project.getDiagnosticsForFile('test.ts').length).toEqual(0); }); it('should not produce errors from inline test declarations mixing with those of the app', () => {