1
- import { expect , it } from 'vitest'
1
+ import { describe , expect , it } from 'vitest'
2
2
import { createRoutesContext } from '../src/core/context'
3
- import { DEFAULT_OPTIONS , resolveOptions } from '../src/options'
4
- import { fileURLToPath , URL } from 'url'
3
+ import { resolveOptions } from '../src/options'
4
+ import { fileURLToPath , URL } from 'node: url'
5
5
import { normalize , join } from 'pathe'
6
6
7
7
const __dirname = fileURLToPath ( new URL ( './' , import . meta. url ) )
@@ -10,24 +10,62 @@ const __dirname = fileURLToPath(new URL('./', import.meta.url))
10
10
* This is a simple full test to check that all filenames are valid in different environment (windows, mac, linux).
11
11
*/
12
12
13
- it ( 'generates the routes' , async ( ) => {
14
- const context = createRoutesContext (
15
- resolveOptions ( {
16
- // dts: join(__dirname, './__types.d.ts'),
17
- dts : false ,
18
- logs : false ,
19
- routesFolder : [ { src : join ( __dirname , './fixtures/filenames/routes' ) } ] ,
20
- } )
21
- )
13
+ describe ( 'e2e routes' , ( ) => {
14
+ it ( 'generates the routes' , async ( ) => {
15
+ const context = createRoutesContext (
16
+ resolveOptions ( {
17
+ // dts: join(__dirname, './__types.d.ts'),
18
+ dts : false ,
19
+ logs : false ,
20
+ watch : false ,
21
+ routesFolder : [ { src : join ( __dirname , './fixtures/filenames/routes' ) } ] ,
22
+ } )
23
+ )
22
24
23
- await context . scanPages ( )
24
- expect (
25
- context
26
- . generateRoutes ( )
27
- . replace (
28
- / i m p o r t \( [ " ' ] ( .+ ?) [ " ' ] \) / g,
29
- ( _ , filePath ) => `import('${ normalize ( filePath ) } ')`
30
- )
31
- . replace ( / ( i m p o r t \( [ " ' ] ) (?: .+ ?) f i x t u r e s \/ f i l e n a m e s / gi, '$1' )
32
- ) . toMatchSnapshot ( )
25
+ await context . scanPages ( )
26
+ expect (
27
+ context
28
+ . generateRoutes ( )
29
+ . replace (
30
+ / i m p o r t \( [ " ' ] ( .+ ?) [ " ' ] \) / g,
31
+ ( _ , filePath ) => `import('${ normalize ( filePath ) } ')`
32
+ )
33
+ . replace ( / ( i m p o r t \( [ " ' ] ) (?: .+ ?) f i x t u r e s \/ f i l e n a m e s / gi, '$1' )
34
+ ) . toMatchSnapshot ( )
35
+ } )
36
+
37
+ it . skip ( 'works with mixed extensions' , async ( ) => {
38
+ const context = createRoutesContext (
39
+ resolveOptions ( {
40
+ dts : false ,
41
+ logs : false ,
42
+ watch : false ,
43
+ routesFolder : [
44
+ {
45
+ src : join ( __dirname , './fixtures/filenames/multi-extensions' ) ,
46
+ exclude : join (
47
+ __dirname ,
48
+ './fixtures/filenames/multi-extensions/docs'
49
+ ) ,
50
+ } ,
51
+ {
52
+ src : join ( __dirname , './fixtures/filenames/multi-extensions/docs' ) ,
53
+ extensions : [ '.md' , '.vue' ] ,
54
+ path : 'docs/[lang]/' ,
55
+ } ,
56
+ ] ,
57
+ } )
58
+ )
59
+
60
+ await context . scanPages ( )
61
+ expect (
62
+ context
63
+ . generateRoutes ( )
64
+ . replace (
65
+ / i m p o r t \( [ " ' ] ( .+ ?) [ " ' ] \) / g,
66
+ ( _ , filePath ) => `import('${ normalize ( filePath ) } ')`
67
+ )
68
+ . replace ( / ( i m p o r t \( [ " ' ] ) (?: .+ ?) f i x t u r e s \/ f i l e n a m e s / gi, '$1' )
69
+ ) . toMatchSnapshot ( )
70
+ } )
33
71
} )
0 commit comments