1
+ namespace ts {
2
+ describe ( "unittests:: services:: projectService" , ( ) => {
3
+ it ( "does not return default configured projects for node_modules" , ( ) => {
4
+ const rootFilePath = server . asNormalizedPath ( "/project/index.ts" ) ;
5
+ const rootProjectPath = server . asNormalizedPath ( "/project/tsconfig.json" ) ;
6
+ const nodeModulesFilePath1 = server . asNormalizedPath ( "/project/node_modules/@types/a/index.d.ts" ) ;
7
+ const nodeModulesProjectPath1 = server . asNormalizedPath ( "/project/node_modules/@types/a/tsconfig.json" ) ;
8
+ const nodeModulesFilePath2 = server . asNormalizedPath ( "/project/node_modules/@types/b/index.d.ts" ) ;
9
+ const serverHost = projectSystem . createServerHost ( [
10
+ { path : rootFilePath , content : "import 'a'; import 'b';" } ,
11
+ { path : rootProjectPath , content : "{}" } ,
12
+ { path : nodeModulesFilePath1 , content : "{}" } ,
13
+ { path : nodeModulesProjectPath1 , content : "{}" } ,
14
+ { path : nodeModulesFilePath2 , content : "{}" } ,
15
+ ] ) ;
16
+ const projectService = projectSystem . createProjectService ( serverHost , { useSingleInferredProject : true } ) ;
17
+
18
+ const openRootFileResult = projectService . openClientFile ( rootFilePath ) ;
19
+ assert . strictEqual ( openRootFileResult . configFileName ?. toString ( ) , rootProjectPath ) ;
20
+
21
+ const openNodeModulesFileResult1 = projectService . openClientFile ( nodeModulesFilePath1 ) ;
22
+ assert . strictEqual ( openNodeModulesFileResult1 . configFileName ?. toString ( ) , nodeModulesProjectPath1 ) ;
23
+
24
+ const openNodeModulesFileResult2 = projectService . openClientFile ( nodeModulesFilePath2 ) ;
25
+ assert . isUndefined ( openNodeModulesFileResult2 . configFileName ) ;
26
+
27
+ const rootProject = projectService . findProject ( rootProjectPath ) ! ;
28
+ assert . isTrue ( rootProject . containsFile ( rootFilePath ) ) ;
29
+ assert . isTrue ( rootProject . containsFile ( nodeModulesFilePath1 ) ) ;
30
+ assert . isTrue ( rootProject . containsFile ( nodeModulesFilePath2 ) ) ;
31
+ } ) ;
32
+ } ) ;
33
+ }
0 commit comments