@@ -2,31 +2,23 @@ import * as ts from "typescript";
22import * as tstl from "../../src" ;
33import { resolveFixture , transpileFilesResult } from "./run" ;
44
5- interface DirectoryTestCase {
6- name : string ;
7- options : tstl . CompilerOptions ;
8- }
5+ const projectRoot = resolveFixture ( "directories" ) ;
6+ test . each ( [ { } , { outDir : "out" } , { rootDir : "src" } , { rootDir : "src" , outDir : "out" } ] ) (
7+ "should be able to resolve (%p)" ,
8+ tsconfigOptions => {
9+ jest . spyOn ( process , "cwd" ) . mockReturnValue ( projectRoot ) ;
910
10- test . each < DirectoryTestCase > ( [
11- { name : "basic" , options : { } } ,
12- { name : "basic" , options : { outDir : "out" } } ,
13- { name : "basic" , options : { rootDir : "src" } } ,
14- { name : "basic" , options : { rootDir : "src" , outDir : "out" } } ,
15- { name : "baseurl" , options : { baseUrl : "./src/lib" , rootDir : "." , outDir : "./out" } } ,
16- ] ) ( "should be able to resolve (%p)" , ( { name, options : compilerOptions } ) => {
17- const projectPath = resolveFixture ( `directories/${ name } ` ) ;
18- jest . spyOn ( process , "cwd" ) . mockReturnValue ( projectPath ) ;
11+ const config = {
12+ compilerOptions : { ...tsconfigOptions , types : [ ] , skipLibCheck : true } ,
13+ tstl : { luaTarget : tstl . LuaTarget . LuaJIT , luaLibImport : tstl . LuaLibImportKind . Always } ,
14+ } ;
1915
20- const config = {
21- compilerOptions : { ...compilerOptions , types : [ ] , skipLibCheck : true } ,
22- tstl : { luaTarget : tstl . LuaTarget . LuaJIT , luaLibImport : tstl . LuaLibImportKind . Always } ,
23- } ;
16+ const { fileNames, options } = tstl . updateParsedConfigFile (
17+ ts . parseJsonConfigFileContent ( config , ts . sys , projectRoot )
18+ ) ;
2419
25- const { fileNames, options } = tstl . updateParsedConfigFile (
26- ts . parseJsonConfigFileContent ( config , ts . sys , projectPath )
27- ) ;
28-
29- const { diagnostics, emittedFiles } = transpileFilesResult ( fileNames , options ) ;
30- expect ( diagnostics ) . not . toHaveDiagnostics ( ) ;
31- expect ( emittedFiles . map ( f => f . name ) . sort ( ) ) . toMatchSnapshot ( ) ;
32- } ) ;
20+ const { diagnostics, emittedFiles } = transpileFilesResult ( fileNames , options ) ;
21+ expect ( diagnostics ) . not . toHaveDiagnostics ( ) ;
22+ expect ( emittedFiles . map ( f => f . name ) . sort ( ) ) . toMatchSnapshot ( ) ;
23+ }
24+ ) ;
0 commit comments