77 */
88
99import * as fs from 'fs' ;
10+ import { join } from 'path' ;
1011import { promisify } from 'util' ;
1112import { MessageConnection } from 'vscode-jsonrpc' ;
1213import * as lsp from 'vscode-languageserver-protocol' ;
1314import { URI } from 'vscode-uri' ;
1415
1516import { ProjectLanguageService , ProjectLanguageServiceParams , SuggestStrictMode , SuggestStrictModeParams } from '../../common/notifications' ;
1617import { GetComponentsWithTemplateFile , GetTcbRequest , GetTemplateLocationForComponent , IsInAngularProject } from '../../common/requests' ;
17- import { APP_COMPONENT , APP_COMPONENT_MODULE_URI , APP_COMPONENT_URI , BAR_COMPONENT , BAR_COMPONENT_URI , FOO_COMPONENT , FOO_COMPONENT_URI , FOO_TEMPLATE , FOO_TEMPLATE_URI , IS_BAZEL , PROJECT_PATH , TSCONFIG } from '../test_constants' ;
18+ import { APP_COMPONENT , APP_COMPONENT_MODULE_URI , APP_COMPONENT_URI , BAR_COMPONENT , BAR_COMPONENT_URI , FOO_COMPONENT , FOO_COMPONENT_URI , FOO_TEMPLATE , FOO_TEMPLATE_URI , IS_BAZEL , PRE_STANDALONE_PROJECT_PATH , PROJECT_PATH , TSCONFIG } from '../test_constants' ;
1819
19- import { convertPathToFileUrl , createConnection , createTracer , initializeServer , openTextDocument } from './test_utils' ;
20+ import { convertPathToFileUrl , createConnection , createTracer , initializeServer , openTextDocument , ServerOptions } from './test_utils' ;
2021
2122const setTimeoutP = promisify ( setTimeout ) ;
2223
@@ -26,20 +27,25 @@ describe('Angular Ivy language server', () => {
2627 let client : MessageConnection ;
2728
2829 beforeEach ( async ( ) => {
30+ await initServer ( { } ) ;
31+ } ) ;
32+
33+ afterEach ( ( ) => {
34+ client . dispose ( ) ;
35+ } ) ;
36+
37+ async function initServer ( options : Partial < ServerOptions > ) {
2938 client = createConnection ( {
3039 ivy : true ,
40+ ...options ,
3141 } ) ;
3242 // If debugging, set to
3343 // - lsp.Trace.Messages to inspect request/response/notification, or
3444 // - lsp.Trace.Verbose to inspect payload
3545 client . trace ( lsp . Trace . Off , createTracer ( ) ) ;
3646 client . listen ( ) ;
3747 await initializeServer ( client ) ;
38- } ) ;
39-
40- afterEach ( ( ) => {
41- client . dispose ( ) ;
42- } ) ;
48+ }
4349
4450 it ( 'should handle hover on inline template' , async ( ) => {
4551 openTextDocument ( client , APP_COMPONENT ) ;
@@ -547,6 +553,15 @@ export class AppComponent {
547553 expect ( response ) . toBeNull ( ) ;
548554 } ) ;
549555
556+ it ( 'should handle apps where standalone is not enabled by default (pre v19)' , async ( ) => {
557+ await initServer ( { angularCoreVersion : '18.0.0' } )
558+ const moduleFile = join ( PRE_STANDALONE_PROJECT_PATH , 'app/app.module.ts' ) ;
559+
560+ openTextDocument ( client , moduleFile ) ;
561+ const diagnostics = await getDiagnosticsForFile ( client , moduleFile ) ;
562+ expect ( diagnostics . length ) . toBe ( 0 ) ;
563+ } ) ;
564+
550565 it ( 'should provide a "go to component" codelens' , async ( ) => {
551566 openTextDocument ( client , FOO_TEMPLATE ) ;
552567 const codeLensResponse = await client . sendRequest ( lsp . CodeLensRequest . type , {
0 commit comments