1+ import path from 'node:path' ;
2+
13import { describe , expect , it } from 'vitest' ;
24
35import {
@@ -18,191 +20,233 @@ import {
1820} from './__tests__/mutator-test-files/named-export-tests' ;
1921import { getMutatorInfo } from './mutator-info' ;
2022
21- const basePath = 'packages/core/src/generators/ __tests__/mutator-test-files';
23+ const basePath = path . join ( import . meta . dirname , ' __tests__/mutator-test-files') ;
2224
2325describe ( 'getMutatorInfo' , ( ) => {
2426 describe ( 'default anonymous export' , ( ) => {
2527 it ( 'should work for anonymous function with 0 args' , async ( ) => {
2628 const result = await getMutatorInfo (
27- ` ${ basePath } / default-anonymous-function-0-args.ts` ,
29+ path . join ( basePath , ' default-anonymous-function-0-args.ts' ) ,
2830 ) ;
2931 expect ( result ) . toEqual ( { numberOfParams : 0 } ) ;
3032 } ) ;
3133
3234 it ( 'should work for anonymous function with 1 args' , async ( ) => {
3335 const result = await getMutatorInfo (
34- ` ${ basePath } / default-anonymous-function-1-args.ts` ,
36+ path . join ( basePath , ' default-anonymous-function-1-args.ts' ) ,
3537 ) ;
3638 expect ( result ) . toEqual ( { numberOfParams : 1 } ) ;
3739 } ) ;
3840
3941 it ( 'should work for anonymous function with 2 args' , async ( ) => {
4042 const result = await getMutatorInfo (
41- ` ${ basePath } / default-anonymous-function-2-args.ts` ,
43+ path . join ( basePath , ' default-anonymous-function-2-args.ts' ) ,
4244 ) ;
4345 expect ( result ) . toEqual ( { numberOfParams : 2 } ) ;
4446 } ) ;
4547
4648 it ( 'should work for anonymous function with 3 args' , async ( ) => {
4749 const result = await getMutatorInfo (
48- ` ${ basePath } / default-anonymous-function-3-args.ts` ,
50+ path . join ( basePath , ' default-anonymous-function-3-args.ts' ) ,
4951 ) ;
5052 expect ( result ) . toEqual ( { numberOfParams : 3 } ) ;
5153 } ) ;
5254
5355 it ( 'should work for anonymous lambda with 0 args' , async ( ) => {
5456 const result = await getMutatorInfo (
55- ` ${ basePath } / default-anonymous-lambda-0-args.ts` ,
57+ path . join ( basePath , ' default-anonymous-lambda-0-args.ts' ) ,
5658 ) ;
5759 expect ( result ) . toEqual ( { numberOfParams : 0 } ) ;
5860 } ) ;
5961
6062 it ( 'should work for anonymous lambda with 1 args' , async ( ) => {
6163 const result = await getMutatorInfo (
62- ` ${ basePath } / default-anonymous-lambda-1-args.ts` ,
64+ path . join ( basePath , ' default-anonymous-lambda-1-args.ts' ) ,
6365 ) ;
6466 expect ( result ) . toEqual ( { numberOfParams : 1 } ) ;
6567 } ) ;
6668
6769 it ( 'should work for anonymous lambda with 2 args' , async ( ) => {
6870 const result = await getMutatorInfo (
69- ` ${ basePath } / default-anonymous-lambda-2-args.ts` ,
71+ path . join ( basePath , ' default-anonymous-lambda-2-args.ts' ) ,
7072 ) ;
7173 expect ( result ) . toEqual ( { numberOfParams : 2 } ) ;
7274 } ) ;
7375
7476 it ( 'should work for anonymous lambda with 3 args' , async ( ) => {
7577 const result = await getMutatorInfo (
76- ` ${ basePath } / default-anonymous-lambda-3-args.ts` ,
78+ path . join ( basePath , ' default-anonymous-lambda-3-args.ts' ) ,
7779 ) ;
7880 expect ( result ) . toEqual ( { numberOfParams : 3 } ) ;
7981 } ) ;
8082
8183 it ( 'should work for anonymous lambda returning lambda with 0 args' , async ( ) => {
8284 const result = await getMutatorInfo (
83- ` ${ basePath } / default-anonymous-nested-lambda-0-args.ts` ,
85+ path . join ( basePath , ' default-anonymous-nested-lambda-0-args.ts' ) ,
8486 ) ;
8587 expect ( result ) . toEqual ( { numberOfParams : 0 , returnNumberOfParams : 0 } ) ;
8688 } ) ;
8789
8890 it ( 'should work for anonymous lambda returning lambda with 1 args' , async ( ) => {
8991 const result = await getMutatorInfo (
90- ` ${ basePath } / default-anonymous-nested-lambda-1-args.ts` ,
92+ path . join ( basePath , ' default-anonymous-nested-lambda-1-args.ts' ) ,
9193 ) ;
9294 expect ( result ) . toEqual ( { numberOfParams : 0 , returnNumberOfParams : 1 } ) ;
9395 } ) ;
9496
9597 it ( 'should work for anonymous lambda returning lambda with 2 args' , async ( ) => {
9698 const result = await getMutatorInfo (
97- ` ${ basePath } / default-anonymous-nested-lambda-2-args.ts` ,
99+ path . join ( basePath , ' default-anonymous-nested-lambda-2-args.ts' ) ,
98100 ) ;
99101 expect ( result ) . toEqual ( { numberOfParams : 0 , returnNumberOfParams : 2 } ) ;
100102 } ) ;
101103
102104 it ( 'should work for anonymous lambda returning lambda with 3 args' , async ( ) => {
103105 const result = await getMutatorInfo (
104- ` ${ basePath } / default-anonymous-nested-lambda-3-args.ts` ,
106+ path . join ( basePath , ' default-anonymous-nested-lambda-3-args.ts' ) ,
105107 ) ;
106108 expect ( result ) . toEqual ( { numberOfParams : 0 , returnNumberOfParams : 3 } ) ;
107109 } ) ;
108110 } ) ;
109111
110112 describe ( 'named export' , ( ) => {
111113 it ( 'should work for function with 0 args' , async ( ) => {
112- const result = await getMutatorInfo ( `${ basePath } /named-export-tests.ts` , {
113- namedExport : fn0Param . name ,
114- } ) ;
114+ const result = await getMutatorInfo (
115+ path . join ( basePath , 'named-export-tests.ts' ) ,
116+ {
117+ namedExport : fn0Param . name ,
118+ } ,
119+ ) ;
115120 expect ( result ) . toEqual ( { numberOfParams : 0 } ) ;
116121 } ) ;
117122
118123 it ( 'should work for function with 1 args' , async ( ) => {
119- const result = await getMutatorInfo ( `${ basePath } /named-export-tests.ts` , {
120- namedExport : fn1Param . name ,
121- } ) ;
124+ const result = await getMutatorInfo (
125+ path . join ( basePath , 'named-export-tests.ts' ) ,
126+ {
127+ namedExport : fn1Param . name ,
128+ } ,
129+ ) ;
122130 expect ( result ) . toEqual ( { numberOfParams : 1 } ) ;
123131 } ) ;
124132
125133 it ( 'should work for function with 2 args' , async ( ) => {
126- const result = await getMutatorInfo ( `${ basePath } /named-export-tests.ts` , {
127- namedExport : fn2Param . name ,
128- } ) ;
134+ const result = await getMutatorInfo (
135+ path . join ( basePath , 'named-export-tests.ts' ) ,
136+ {
137+ namedExport : fn2Param . name ,
138+ } ,
139+ ) ;
129140 expect ( result ) . toEqual ( { numberOfParams : 2 } ) ;
130141 } ) ;
131142
132143 it ( 'should work for function with 3 args' , async ( ) => {
133- const result = await getMutatorInfo ( `${ basePath } /named-export-tests.ts` , {
134- namedExport : fn3Param . name ,
135- } ) ;
144+ const result = await getMutatorInfo (
145+ path . join ( basePath , 'named-export-tests.ts' ) ,
146+ {
147+ namedExport : fn3Param . name ,
148+ } ,
149+ ) ;
136150 expect ( result ) . toEqual ( { numberOfParams : 3 } ) ;
137151 } ) ;
138152
139153 it ( 'should work for lambda with 0 args' , async ( ) => {
140- const result = await getMutatorInfo ( `${ basePath } /named-export-tests.ts` , {
141- namedExport : lambda0Param . name ,
142- } ) ;
154+ const result = await getMutatorInfo (
155+ path . join ( basePath , 'named-export-tests.ts' ) ,
156+ {
157+ namedExport : lambda0Param . name ,
158+ } ,
159+ ) ;
143160 expect ( result ) . toEqual ( { numberOfParams : 0 } ) ;
144161 } ) ;
145162
146163 it ( 'should work for lambda with 1 args' , async ( ) => {
147- const result = await getMutatorInfo ( `${ basePath } /named-export-tests.ts` , {
148- namedExport : lambda1Param . name ,
149- } ) ;
164+ const result = await getMutatorInfo (
165+ path . join ( basePath , 'named-export-tests.ts' ) ,
166+ {
167+ namedExport : lambda1Param . name ,
168+ } ,
169+ ) ;
150170 expect ( result ) . toEqual ( { numberOfParams : 1 } ) ;
151171 } ) ;
152172
153173 it ( 'should work for lambda with 2 args' , async ( ) => {
154- const result = await getMutatorInfo ( `${ basePath } /named-export-tests.ts` , {
155- namedExport : lambda2Param . name ,
156- } ) ;
174+ const result = await getMutatorInfo (
175+ path . join ( basePath , 'named-export-tests.ts' ) ,
176+ {
177+ namedExport : lambda2Param . name ,
178+ } ,
179+ ) ;
157180 expect ( result ) . toEqual ( { numberOfParams : 2 } ) ;
158181 } ) ;
159182
160183 it ( 'should work for lambda with 3 args' , async ( ) => {
161- const result = await getMutatorInfo ( `${ basePath } /named-export-tests.ts` , {
162- namedExport : lambda3Param . name ,
163- } ) ;
184+ const result = await getMutatorInfo (
185+ path . join ( basePath , 'named-export-tests.ts' ) ,
186+ {
187+ namedExport : lambda3Param . name ,
188+ } ,
189+ ) ;
164190 expect ( result ) . toEqual ( { numberOfParams : 3 } ) ;
165191 } ) ;
166192
167193 it ( 'should work for lambda returning lambda with 0 args' , async ( ) => {
168- const result = await getMutatorInfo ( `${ basePath } /named-export-tests.ts` , {
169- namedExport : nestedLambda0Param . name ,
170- } ) ;
194+ const result = await getMutatorInfo (
195+ path . join ( basePath , 'named-export-tests.ts' ) ,
196+ {
197+ namedExport : nestedLambda0Param . name ,
198+ } ,
199+ ) ;
171200 expect ( result ) . toEqual ( { numberOfParams : 0 , returnNumberOfParams : 0 } ) ;
172201 } ) ;
173202
174203 it ( 'should work for lambda returning lambda with 1 args' , async ( ) => {
175- const result = await getMutatorInfo ( `${ basePath } /named-export-tests.ts` , {
176- namedExport : nestedLambda1Param . name ,
177- } ) ;
204+ const result = await getMutatorInfo (
205+ path . join ( basePath , 'named-export-tests.ts' ) ,
206+ {
207+ namedExport : nestedLambda1Param . name ,
208+ } ,
209+ ) ;
178210 expect ( result ) . toEqual ( { numberOfParams : 0 , returnNumberOfParams : 1 } ) ;
179211 } ) ;
180212
181213 it ( 'should work for lambda returning lambda with 2 args' , async ( ) => {
182- const result = await getMutatorInfo ( `${ basePath } /named-export-tests.ts` , {
183- namedExport : nestedLambda2Param . name ,
184- } ) ;
214+ const result = await getMutatorInfo (
215+ path . join ( basePath , 'named-export-tests.ts' ) ,
216+ {
217+ namedExport : nestedLambda2Param . name ,
218+ } ,
219+ ) ;
185220 expect ( result ) . toEqual ( { numberOfParams : 0 , returnNumberOfParams : 2 } ) ;
186221 } ) ;
187222
188223 it ( 'should work for lambda returning lambda with 3 args' , async ( ) => {
189- const result = await getMutatorInfo ( `${ basePath } /named-export-tests.ts` , {
190- namedExport : nestedLambda3Param . name ,
191- } ) ;
224+ const result = await getMutatorInfo (
225+ path . join ( basePath , 'named-export-tests.ts' ) ,
226+ {
227+ namedExport : nestedLambda3Param . name ,
228+ } ,
229+ ) ;
192230 expect ( result ) . toEqual ( { numberOfParams : 0 , returnNumberOfParams : 3 } ) ;
193231 } ) ;
194232
195233 it ( 'should work for callback function with 2 args' , async ( ) => {
196- const result = await getMutatorInfo ( `${ basePath } /named-export-tests.ts` , {
197- namedExport : fnCallback . name ,
198- } ) ;
234+ const result = await getMutatorInfo (
235+ path . join ( basePath , 'named-export-tests.ts' ) ,
236+ {
237+ namedExport : fnCallback . name ,
238+ } ,
239+ ) ;
199240 expect ( result ) . toEqual ( { numberOfParams : 2 } ) ;
200241 } ) ;
201242
202243 it ( 'should work for function returning lambda with 2 args' , async ( ) => {
203- const result = await getMutatorInfo ( `${ basePath } /named-export-tests.ts` , {
204- namedExport : fnNestedLambda2Param . name ,
205- } ) ;
244+ const result = await getMutatorInfo (
245+ path . join ( basePath , 'named-export-tests.ts' ) ,
246+ {
247+ namedExport : fnNestedLambda2Param . name ,
248+ } ,
249+ ) ;
206250 expect ( result ) . toEqual ( { numberOfParams : 0 , returnNumberOfParams : 2 } ) ;
207251 } ) ;
208252 } ) ;
0 commit comments