@@ -4,13 +4,13 @@ import {fileURLToPath} from 'node:url';
44import test from 'ava' ;
55import createProviderMacro from './_with-provider.js' ;
66
7- const projectDir = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
8- const pkg = JSON . parse ( fs . readFileSync ( new URL ( '../package.json' , import . meta. url ) ) ) ;
7+ const projectDirectory = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
8+ const package_ = JSON . parse ( fs . readFileSync ( new URL ( '../package.json' , import . meta. url ) ) ) ;
99const withProvider = createProviderMacro ( 'ava-6' , '5.3.0' ) ;
1010
1111const validateConfig = ( t , provider , config ) => {
1212 const error = t . throws ( ( ) => provider . main ( { config} ) ) ;
13- error . message = error . message . replace ( `v${ pkg . version } ` , 'v${pkg.version}' ) ; // eslint-disable-line no-template-curly-in-string
13+ error . message = error . message . replace ( `v${ package_ . version } ` , 'v${pkg.version}' ) ; // eslint-disable-line no-template-curly-in-string
1414 t . snapshot ( error ) ;
1515} ;
1616
@@ -77,64 +77,64 @@ test('main() updateGlobs()', withProvider, (t, provider) => {
7777
7878test ( 'main() interpretChange() without compilation' , withProvider , ( t , provider ) => {
7979 const main = provider . main ( { config : { rewritePaths : { 'src/' : 'build/' } , compile : false } } ) ;
80- t . is ( main . interpretChange ( path . join ( projectDir , 'src/foo.ts' ) ) , main . changeInterpretations . waitForOutOfBandCompilation ) ;
81- t . is ( main . interpretChange ( path . join ( projectDir , 'build/foo.js' ) ) , main . changeInterpretations . unspecified ) ;
82- t . is ( main . interpretChange ( path . join ( projectDir , 'src/foo.txt' ) ) , main . changeInterpretations . unspecified ) ;
80+ t . is ( main . interpretChange ( path . join ( projectDirectory , 'src/foo.ts' ) ) , main . changeInterpretations . waitForOutOfBandCompilation ) ;
81+ t . is ( main . interpretChange ( path . join ( projectDirectory , 'build/foo.js' ) ) , main . changeInterpretations . unspecified ) ;
82+ t . is ( main . interpretChange ( path . join ( projectDirectory , 'src/foo.txt' ) ) , main . changeInterpretations . unspecified ) ;
8383} ) ;
8484
8585test ( 'main() interpretChange() with compilation' , withProvider , ( t , provider ) => {
8686 const main = provider . main ( { config : { rewritePaths : { 'src/' : 'build/' } , compile : 'tsc' } } ) ;
87- t . is ( main . interpretChange ( path . join ( projectDir , 'src/foo.ts' ) ) , main . changeInterpretations . unspecified ) ;
88- t . is ( main . interpretChange ( path . join ( projectDir , 'build/foo.js' ) ) , main . changeInterpretations . ignoreCompiled ) ;
89- t . is ( main . interpretChange ( path . join ( projectDir , 'src/foo.txt' ) ) , main . changeInterpretations . unspecified ) ;
87+ t . is ( main . interpretChange ( path . join ( projectDirectory , 'src/foo.ts' ) ) , main . changeInterpretations . unspecified ) ;
88+ t . is ( main . interpretChange ( path . join ( projectDirectory , 'build/foo.js' ) ) , main . changeInterpretations . ignoreCompiled ) ;
89+ t . is ( main . interpretChange ( path . join ( projectDirectory , 'src/foo.txt' ) ) , main . changeInterpretations . unspecified ) ;
9090} ) ;
9191
9292test ( 'main() resolvePossibleOutOfBandCompilationSources() with compilation' , withProvider , ( t , provider ) => {
9393 const main = provider . main ( { config : { rewritePaths : { 'src/' : 'build/' } , compile : 'tsc' } } ) ;
94- t . is ( main . resolvePossibleOutOfBandCompilationSources ( path . join ( projectDir , 'build/foo.js' ) ) , null ) ;
94+ t . is ( main . resolvePossibleOutOfBandCompilationSources ( path . join ( projectDirectory , 'build/foo.js' ) ) , null ) ;
9595} ) ;
9696
9797test ( 'main() resolvePossibleOutOfBandCompilationSources() unknown extension' , withProvider , ( t , provider ) => {
9898 const main = provider . main ( { config : { rewritePaths : { 'src/' : 'build/' } , compile : false } } ) ;
99- t . is ( main . resolvePossibleOutOfBandCompilationSources ( path . join ( projectDir , 'build/foo.bar' ) ) , null ) ;
99+ t . is ( main . resolvePossibleOutOfBandCompilationSources ( path . join ( projectDirectory , 'build/foo.bar' ) ) , null ) ;
100100} ) ;
101101
102102test ( 'main() resolvePossibleOutOfBandCompilationSources() not a build path' , withProvider , ( t , provider ) => {
103103 const main = provider . main ( { config : { rewritePaths : { 'src/' : 'build/' } , compile : false } } ) ;
104- t . is ( main . resolvePossibleOutOfBandCompilationSources ( path . join ( projectDir , 'lib/foo.js' ) ) , null ) ;
104+ t . is ( main . resolvePossibleOutOfBandCompilationSources ( path . join ( projectDirectory , 'lib/foo.js' ) ) , null ) ;
105105} ) ;
106106
107107test ( 'main() resolvePossibleOutOfBandCompilationSources() .cjs but .cts not configured' , withProvider , ( t , provider ) => {
108108 const main = provider . main ( { config : { extensions : [ 'ts' ] , rewritePaths : { 'src/' : 'build/' } , compile : false } } ) ;
109- t . is ( main . resolvePossibleOutOfBandCompilationSources ( path . join ( projectDir , 'build/foo.cjs' ) ) , null ) ;
109+ t . is ( main . resolvePossibleOutOfBandCompilationSources ( path . join ( projectDirectory , 'build/foo.cjs' ) ) , null ) ;
110110} ) ;
111111
112112test ( 'main() resolvePossibleOutOfBandCompilationSources() .mjs but .mts not configured' , withProvider , ( t , provider ) => {
113113 const main = provider . main ( { config : { extensions : [ 'ts' ] , rewritePaths : { 'src/' : 'build/' } , compile : false } } ) ;
114- t . is ( main . resolvePossibleOutOfBandCompilationSources ( path . join ( projectDir , 'build/foo.mjs' ) ) , null ) ;
114+ t . is ( main . resolvePossibleOutOfBandCompilationSources ( path . join ( projectDirectory , 'build/foo.mjs' ) ) , null ) ;
115115} ) ;
116116
117117test ( 'main() resolvePossibleOutOfBandCompilationSources() .js but .ts not configured' , withProvider , ( t , provider ) => {
118118 const main = provider . main ( { config : { extensions : [ 'cts' ] , rewritePaths : { 'src/' : 'build/' } , compile : false } } ) ;
119- t . is ( main . resolvePossibleOutOfBandCompilationSources ( path . join ( projectDir , 'build/foo.js' ) ) , null ) ;
119+ t . is ( main . resolvePossibleOutOfBandCompilationSources ( path . join ( projectDirectory , 'build/foo.js' ) ) , null ) ;
120120} ) ;
121121
122122test ( 'main() resolvePossibleOutOfBandCompilationSources() .cjs and .cjs and .cts configured' , withProvider , ( t , provider ) => {
123123 const main = provider . main ( { config : { extensions : [ 'cjs' , 'cts' ] , rewritePaths : { 'src/' : 'build/' } , compile : false } } ) ;
124- t . deepEqual ( main . resolvePossibleOutOfBandCompilationSources ( path . join ( projectDir , 'build/foo.cjs' ) ) , [ path . join ( projectDir , 'src/foo.cjs' ) , path . join ( projectDir , 'src/foo.cts' ) ] ) ;
124+ t . deepEqual ( main . resolvePossibleOutOfBandCompilationSources ( path . join ( projectDirectory , 'build/foo.cjs' ) ) , [ path . join ( projectDirectory , 'src/foo.cjs' ) , path . join ( projectDirectory , 'src/foo.cts' ) ] ) ;
125125} ) ;
126126
127127test ( 'main() resolvePossibleOutOfBandCompilationSources() .mjs and .mjs and .mts configured' , withProvider , ( t , provider ) => {
128128 const main = provider . main ( { config : { extensions : [ 'mjs' , 'mts' ] , rewritePaths : { 'src/' : 'build/' } , compile : false } } ) ;
129- t . deepEqual ( main . resolvePossibleOutOfBandCompilationSources ( path . join ( projectDir , 'build/foo.mjs' ) ) , [ path . join ( projectDir , 'src/foo.mjs' ) , path . join ( projectDir , 'src/foo.mts' ) ] ) ;
129+ t . deepEqual ( main . resolvePossibleOutOfBandCompilationSources ( path . join ( projectDirectory , 'build/foo.mjs' ) ) , [ path . join ( projectDirectory , 'src/foo.mjs' ) , path . join ( projectDirectory , 'src/foo.mts' ) ] ) ;
130130} ) ;
131131
132132test ( 'main() resolvePossibleOutOfBandCompilationSources() .js and .js, .ts and .tsx configured' , withProvider , ( t , provider ) => {
133133 const main = provider . main ( { config : { extensions : [ 'js' , 'ts' , 'tsx' ] , rewritePaths : { 'src/' : 'build/' } , compile : false } } ) ;
134- t . deepEqual ( main . resolvePossibleOutOfBandCompilationSources ( path . join ( projectDir , 'build/foo.js' ) ) , [ path . join ( projectDir , 'src/foo.js' ) , path . join ( projectDir , 'src/foo.ts' ) , path . join ( projectDir , 'src/foo.tsx' ) ] ) ;
134+ t . deepEqual ( main . resolvePossibleOutOfBandCompilationSources ( path . join ( projectDirectory , 'build/foo.js' ) ) , [ path . join ( projectDirectory , 'src/foo.js' ) , path . join ( projectDirectory , 'src/foo.ts' ) , path . join ( projectDirectory , 'src/foo.tsx' ) ] ) ;
135135} ) ;
136136
137137test ( 'main() resolvePossibleOutOfBandCompilationSources() returns the first possible path that exists' , withProvider , ( t , provider ) => {
138138 const main = provider . main ( { config : { extensions : [ 'js' , 'ts' , 'tsx' ] , rewritePaths : { 'fixtures/load/' : 'fixtures/load/compiled/' } , compile : false } } ) ;
139- t . deepEqual ( main . resolvePossibleOutOfBandCompilationSources ( path . join ( projectDir , 'fixtures/load/compiled/index.js' ) ) , [ path . join ( projectDir , 'fixtures/load/index.ts' ) ] ) ;
139+ t . deepEqual ( main . resolvePossibleOutOfBandCompilationSources ( path . join ( projectDirectory , 'fixtures/load/compiled/index.js' ) ) , [ path . join ( projectDirectory , 'fixtures/load/index.ts' ) ] ) ;
140140} ) ;
0 commit comments