@@ -4,13 +4,13 @@ import {fileURLToPath} from 'node:url';
4
4
import test from 'ava' ;
5
5
import createProviderMacro from './_with-provider.js' ;
6
6
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 ) ) ) ;
9
9
const withProvider = createProviderMacro ( 'ava-6' , '5.3.0' ) ;
10
10
11
11
const validateConfig = ( t , provider , config ) => {
12
12
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
14
14
t . snapshot ( error ) ;
15
15
} ;
16
16
@@ -77,64 +77,64 @@ test('main() updateGlobs()', withProvider, (t, provider) => {
77
77
78
78
test ( 'main() interpretChange() without compilation' , withProvider , ( t , provider ) => {
79
79
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 ) ;
83
83
} ) ;
84
84
85
85
test ( 'main() interpretChange() with compilation' , withProvider , ( t , provider ) => {
86
86
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 ) ;
90
90
} ) ;
91
91
92
92
test ( 'main() resolvePossibleOutOfBandCompilationSources() with compilation' , withProvider , ( t , provider ) => {
93
93
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 ) ;
95
95
} ) ;
96
96
97
97
test ( 'main() resolvePossibleOutOfBandCompilationSources() unknown extension' , withProvider , ( t , provider ) => {
98
98
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 ) ;
100
100
} ) ;
101
101
102
102
test ( 'main() resolvePossibleOutOfBandCompilationSources() not a build path' , withProvider , ( t , provider ) => {
103
103
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 ) ;
105
105
} ) ;
106
106
107
107
test ( 'main() resolvePossibleOutOfBandCompilationSources() .cjs but .cts not configured' , withProvider , ( t , provider ) => {
108
108
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 ) ;
110
110
} ) ;
111
111
112
112
test ( 'main() resolvePossibleOutOfBandCompilationSources() .mjs but .mts not configured' , withProvider , ( t , provider ) => {
113
113
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 ) ;
115
115
} ) ;
116
116
117
117
test ( 'main() resolvePossibleOutOfBandCompilationSources() .js but .ts not configured' , withProvider , ( t , provider ) => {
118
118
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 ) ;
120
120
} ) ;
121
121
122
122
test ( 'main() resolvePossibleOutOfBandCompilationSources() .cjs and .cjs and .cts configured' , withProvider , ( t , provider ) => {
123
123
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' ) ] ) ;
125
125
} ) ;
126
126
127
127
test ( 'main() resolvePossibleOutOfBandCompilationSources() .mjs and .mjs and .mts configured' , withProvider , ( t , provider ) => {
128
128
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' ) ] ) ;
130
130
} ) ;
131
131
132
132
test ( 'main() resolvePossibleOutOfBandCompilationSources() .js and .js, .ts and .tsx configured' , withProvider , ( t , provider ) => {
133
133
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' ) ] ) ;
135
135
} ) ;
136
136
137
137
test ( 'main() resolvePossibleOutOfBandCompilationSources() returns the first possible path that exists' , withProvider , ( t , provider ) => {
138
138
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' ) ] ) ;
140
140
} ) ;
0 commit comments