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
This commit is contained in:
parent
f93eae7708
commit
23360d1215
@ -6,11 +6,9 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* 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 {initMockFileSystem} from '@angular/compiler-cli/src/ngtsc/file_system/testing';
|
||||||
|
|
||||||
import {isNgSpecificDiagnostic, LanguageServiceTestEnv} from '../testing';
|
import {isNgSpecificDiagnostic, LanguageServiceTestEnv} from '../testing';
|
||||||
import {LanguageServiceTestEnvironment} from './env';
|
|
||||||
|
|
||||||
describe('language-service/compiler integration', () => {
|
describe('language-service/compiler integration', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -18,13 +16,9 @@ describe('language-service/compiler integration', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should react to a change in an external template', () => {
|
it('should react to a change in an external template', () => {
|
||||||
const cmpFile = absoluteFrom('/test.ts');
|
const env = LanguageServiceTestEnv.setup();
|
||||||
const tmplFile = absoluteFrom('/test.html');
|
const project = env.addProject('test', {
|
||||||
|
'test.ts': `
|
||||||
const env = LanguageServiceTestEnvironment.setup([
|
|
||||||
{
|
|
||||||
name: cmpFile,
|
|
||||||
contents: `
|
|
||||||
import {Component} from '@angular/core';
|
import {Component} from '@angular/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -33,20 +27,14 @@ describe('language-service/compiler integration', () => {
|
|||||||
})
|
})
|
||||||
export class TestCmp {}
|
export class TestCmp {}
|
||||||
`,
|
`,
|
||||||
isRoot: true,
|
'test.html': `<other-cmp>Test</other-cmp>`
|
||||||
},
|
});
|
||||||
{
|
|
||||||
name: tmplFile,
|
|
||||||
contents: '<other-cmp>Test</other-cmp>',
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
|
|
||||||
const diags = env.ngLS.getSemanticDiagnostics(cmpFile);
|
expect(project.getDiagnosticsForFile('test.ts').length).toBeGreaterThan(0);
|
||||||
expect(diags.length).toBeGreaterThan(0);
|
|
||||||
|
|
||||||
env.updateFile(tmplFile, '<div>Test</div>');
|
const tmplFile = project.openFile('test.html');
|
||||||
const afterDiags = env.ngLS.getSemanticDiagnostics(cmpFile);
|
tmplFile.contents = '<div>Test</div>';
|
||||||
expect(afterDiags.length).toBe(0);
|
expect(project.getDiagnosticsForFile('test.ts').length).toEqual(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not produce errors from inline test declarations mixing with those of the app', () => {
|
it('should not produce errors from inline test declarations mixing with those of the app', () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user