/
githubmirror
/
angular
Обзор
Документация
Войти
/
githubmirror
/
angular
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/language-service/test/version_detection_spec.ts
56 строк
2 KB
Andrew Scott
test(language-service): optimize language service test environment and flatten test setup
16 мар 2026, 23:49
16 мар 2026, 23:49
470cf43
Код
Авторство
О чём код?
/** * @license * Copyright Google LLC 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.dev/license */ import {LanguageServiceTestEnv} from '../testing'; describe('Angular version detection', () => { let env: LanguageServiceTestEnv; beforeEach(() => { env = LanguageServiceTestEnv.setup(); }); it('should detect Angular version per project', () => { // Project 1: Angular v16 const project1 = env.addProject('project1', { 'tsconfig.json': '{}', 'app.ts': 'export class App {}', 'node_modules/@angular/core/package.json': JSON.stringify({ name: '@angular/core', version: '16.0.0', }), }); // Project 2: Angular v17 const project2 = env.addProject('project2', { 'tsconfig.json': '{}', 'app.ts': 'export class App {}', 'node_modules/@angular/core/package.json': JSON.stringify({ name: '@angular/core', version: '17.0.0', }), }); // We need to access the internal options to verify detection // Project wrapper in testing exposes ngLS const options1 = project1.ngLS.getCompilerOptions(); expect(options1['_angularCoreVersion']).toBe('16.0.0'); const options2 = project2.ngLS.getCompilerOptions(); expect(options2['_angularCoreVersion']).toBe('17.0.0'); }); it('should fallback to default if detection fails', () => { const project = env.addProject('project-no-core', { 'tsconfig.json': '{}', 'app.ts': 'export class App {}', }); const options = project.ngLS.getCompilerOptions(); expect(options['_angularCoreVersion']).toBeUndefined(); }); });