@@ -84,31 +84,33 @@ describe("basic module resolution", () => {
8484
8585describe ( "module resolution with chained dependencies" , ( ) => {
8686 const projectPath = path . resolve ( __dirname , "module-resolution" , "project-with-dependency-chain" ) ;
87+ const expectedResult = { result : "dependency3" } ;
8788
8889 test ( "can resolve dependencies in chain" , ( ) => {
8990 util . testProject ( path . join ( projectPath , "tsconfig.json" ) )
9091 . setMainFileName ( path . join ( projectPath , "main.ts" ) )
91- . expectToEqual ( { result : "dependency3" } ) ;
92+ . expectToEqual ( expectedResult ) ;
9293 } ) ;
9394
9495 test ( "resolved package dependency included in bundle" , ( ) => {
9596 const mainFile = path . join ( projectPath , "main.ts" ) ;
9697 util . testProject ( path . join ( projectPath , "tsconfig.json" ) )
9798 . setMainFileName ( mainFile )
9899 . setOptions ( { luaBundle : "bundle.lua" , luaBundleEntry : mainFile } )
99- . expectToEqual ( { result : "dependency3" } ) ;
100+ . expectToEqual ( expectedResult ) ;
100101 } ) ;
101102} ) ;
102103
103104describe ( "module resolution with outDir" , ( ) => {
104105 const projectPath = path . resolve ( __dirname , "module-resolution" , "project-with-dependency-chain" ) ;
106+ const expectedResult = { result : "dependency3" } ;
105107
106108 test ( "emits files in outDir" , ( ) => {
107109 const builder = util
108110 . testProject ( path . join ( projectPath , "tsconfig.json" ) )
109111 . setMainFileName ( path . join ( projectPath , "main.ts" ) )
110112 . setOptions ( { outDir : "tstl-out" } )
111- . expectToEqual ( { result : "dependency3" } ) ;
113+ . expectToEqual ( expectedResult ) ;
112114
113115 // Get the output paths relative to the project path
114116 const outPaths = builder . getLuaResult ( ) . transpiledFiles . map ( f => path . relative ( projectPath , f . outPath ) ) ;
@@ -126,7 +128,7 @@ describe("module resolution with outDir", () => {
126128 . testProject ( path . join ( projectPath , "tsconfig.json" ) )
127129 . setMainFileName ( mainFile )
128130 . setOptions ( { outDir : "tstl-out" , luaBundle : "bundle.lua" , luaBundleEntry : mainFile } )
129- . expectToEqual ( { result : "dependency3" } ) ;
131+ . expectToEqual ( expectedResult ) ;
130132
131133 // Get the output paths relative to the project path
132134 const outPaths = builder . getLuaResult ( ) . transpiledFiles . map ( f => path . relative ( projectPath , f . outPath ) ) ;
@@ -137,19 +139,26 @@ describe("module resolution with outDir", () => {
137139
138140describe ( "module resolution with sourceDir" , ( ) => {
139141 const projectPath = path . resolve ( __dirname , "module-resolution" , "project-with-sourceDir" ) ;
142+ const expectedResult = {
143+ result : "dependency3" ,
144+ functionInSubDir : "non-node_modules import" ,
145+ functionReExportedFromSubDir : "nested func result" ,
146+ nestedFunctionInSubDirOfSubDir : "nested func result" ,
147+ nestedFunctionUsingFunctionFromParentDir : "nested func: non-node_modules import 2" ,
148+ } ;
140149
141150 test ( "can resolve dependencies with sourceDir" , ( ) => {
142151 util . testProject ( path . join ( projectPath , "tsconfig.json" ) )
143152 . setMainFileName ( path . join ( projectPath , "src" , "main.ts" ) )
144153 . setOptions ( { outDir : "tstl-out" } )
145- . expectToEqual ( { result : "dependency3" , result2 : "non-node_modules import" } ) ;
154+ . expectToEqual ( expectedResult ) ;
146155 } ) ;
147156
148157 test ( "can resolve dependencies and bundle files with sourceDir" , ( ) => {
149158 const mainFile = path . join ( projectPath , "src" , "main.ts" ) ;
150159 util . testProject ( path . join ( projectPath , "tsconfig.json" ) )
151160 . setMainFileName ( mainFile )
152161 . setOptions ( { luaBundle : "bundle.lua" , luaBundleEntry : mainFile } )
153- . expectToEqual ( { result : "dependency3" , result2 : "non-node_modules import" } ) ;
162+ . expectToEqual ( expectedResult ) ;
154163 } ) ;
155164} ) ;
0 commit comments