@@ -43,17 +43,37 @@ function testWithRootUri(rootUri: string): void {
43
43
const localfs = new MapFileSystem ( new Map ( [
44
44
[ rootUri + 'project/package.json' , '{"name": "package-name-1"}' ] ,
45
45
[ rootUri + 'project/tsconfig.json' , '{ "compilerOptions": { "typeRoots": ["../types"]} }' ] ,
46
- [ rootUri + 'project/file.ts' , 'console.log(GLOBALCONSTANT);' ] ,
46
+ [ rootUri + 'project/node_modules/%40types/mocha/index.d.ts' , 'declare var describe { (description: string, spec: () => void): void; }' ] ,
47
+ [ rootUri + 'project/file.ts' , 'describe("test", () => console.log(GLOBALCONSTANT));' ] ,
47
48
[ rootUri + 'types/types.d.ts' , 'declare var GLOBALCONSTANT=1;' ]
48
49
49
50
] ) )
50
51
const updater = new FileSystemUpdater ( localfs , memfs )
51
52
projectManager = new ProjectManager ( rootPath , memfs , updater , true )
52
53
} )
54
+
53
55
it ( 'loads files from typeRoots' , async ( ) => {
54
- await projectManager . ensureReferencedFiles ( rootUri + 'project/file.ts' ) . toPromise ( )
55
- memfs . getContent ( rootUri + 'project/file.ts' )
56
- memfs . getContent ( rootUri + 'types/types.d.ts' )
56
+ const sourceFileUri = rootUri + 'project/file.ts'
57
+ const typeRootFileUri = rootUri + 'types/types.d.ts'
58
+ await projectManager . ensureReferencedFiles ( sourceFileUri ) . toPromise ( )
59
+ memfs . getContent ( typeRootFileUri )
60
+
61
+ const config = projectManager . getConfiguration ( uri2path ( sourceFileUri ) , 'ts' )
62
+ const host = config . getHost ( )
63
+ const typeDeclarationPath = uri2path ( typeRootFileUri )
64
+ assert . includeMembers ( host . getScriptFileNames ( ) , [ typeDeclarationPath ] )
65
+ } )
66
+
67
+ it ( 'loads mocha global type declarations' , async ( ) => {
68
+ const sourceFileUri = rootUri + 'project/file.ts'
69
+ const mochaDeclarationFileUri = rootUri + 'project/node_modules/%40types/mocha/index.d.ts'
70
+ await projectManager . ensureReferencedFiles ( sourceFileUri ) . toPromise ( )
71
+ memfs . getContent ( mochaDeclarationFileUri )
72
+
73
+ const config = projectManager . getConfiguration ( uri2path ( sourceFileUri ) , 'ts' )
74
+ const host = config . getHost ( )
75
+ const mochaFilePath = uri2path ( mochaDeclarationFileUri )
76
+ assert . includeMembers ( host . getScriptFileNames ( ) , [ mochaFilePath ] )
57
77
} )
58
78
} )
59
79
0 commit comments