@@ -5,6 +5,8 @@ import { loadConfig } from '../src'
5
5
describe ( 'c12' , ( ) => {
6
6
const r = path => fileURLToPath ( new URL ( path , import . meta. url ) )
7
7
8
+ const transformPaths = obj => JSON . parse ( JSON . stringify ( obj ) . replaceAll ( r ( '.' ) , '<path>/' ) )
9
+
8
10
it ( 'load fixture config' , async ( ) => {
9
11
const { config, layers } = await loadConfig ( {
10
12
cwd : r ( './fixture' ) ,
@@ -23,81 +25,94 @@ describe('c12', () => {
23
25
}
24
26
} )
25
27
26
- expect ( config ) . toMatchObject ( {
27
- configFile : true ,
28
- rcFile : true ,
29
- defaultConfig : true ,
30
- overriden : true ,
31
- baseConfig : true ,
32
- devConfig : true ,
33
- virtual : true ,
34
- colors : {
35
- primary : 'user_primary' ,
36
- secondary : 'theme_secondary' ,
37
- text : 'base_text'
28
+ expect ( transformPaths ( config ) ) . toMatchInlineSnapshot ( `
29
+ {
30
+ "baseConfig": true,
31
+ "colors": {
32
+ "primary": "user_primary",
33
+ "secondary": "theme_secondary",
34
+ "text": "base_text",
35
+ },
36
+ "configFile": true,
37
+ "defaultConfig": true,
38
+ "devConfig": true,
39
+ "extends": [
40
+ "./theme",
41
+ "./config.dev",
42
+ "virtual",
43
+ ],
44
+ "overriden": true,
45
+ "rcFile": true,
46
+ "virtual": true,
38
47
}
39
- } )
48
+ ` )
40
49
41
- expect ( layers ) . toMatchObject ( [
42
- {
43
- config : {
44
- overriden : true ,
45
- extends : [
46
- 'virtual'
47
- ]
50
+ expect ( transformPaths ( layers ) ) . toMatchInlineSnapshot ( `
51
+ [
52
+ {
53
+ "config": {
54
+ "extends": [
55
+ "virtual",
56
+ ],
57
+ "overriden": true,
58
+ },
48
59
},
49
- configFile : undefined ,
50
- cwd : undefined
51
- } ,
52
- {
53
- config : {
54
- extends : [
55
- './theme' ,
56
- './config.dev'
57
- ] ,
58
- colors : {
59
- primary : 'user_primary'
60
+ {
61
+ "config": {
62
+ "colors": {
63
+ "primary": "user_primary",
64
+ },
65
+ "configFile": true,
66
+ "extends": [
67
+ "./theme",
68
+ "./config.dev" ,
69
+ ],
70
+ "overriden": false,
60
71
},
61
- configFile : true ,
62
- overriden : false
72
+ " configFile": "config" ,
73
+ "cwd": "<path>/fixture",
63
74
},
64
- configFile : 'config' ,
65
- cwd : r ( './fixture' )
66
- } ,
67
- {
68
- config : { rcFile : true } ,
69
- configFile : '.configrc'
70
- } ,
71
- {
72
- config : {
73
- colors : {
74
- primary : 'theme_primary' ,
75
- secondary : 'theme_secondary'
76
- }
75
+ {
76
+ "config": {
77
+ "rcFile": true,
78
+ },
79
+ "configFile": ".configrc",
77
80
},
78
- configFile : r ( './fixture/theme/config.ts' ) ,
79
- cwd : r ( './fixture/theme' )
80
- } ,
81
- {
82
- config : {
83
- baseConfig : true ,
84
- colors : {
85
- primary : 'base_primary' ,
86
- text : 'base_text'
87
- }
81
+ {
82
+ "config": {
83
+ "colors": {
84
+ "primary": "theme_primary",
85
+ "secondary": "theme_secondary",
86
+ },
87
+ },
88
+ "configFile": "<path>/fixture/theme/config.ts",
89
+ "cwd": "<path>/fixture/theme",
88
90
},
89
- configFile : r ( './fixture/base/config.ts' ) ,
90
- cwd : r ( './fixture/base' )
91
- } ,
92
- {
93
- config : { devConfig : true } ,
94
- configFile : r ( './fixture/config.dev.ts' ) ,
95
- cwd : r ( './fixture' )
96
- } ,
97
- {
98
- config : { virtual : true }
99
- }
100
- ] )
91
+ {
92
+ "config": {
93
+ "baseConfig": true,
94
+ "colors": {
95
+ "primary": "base_primary",
96
+ "text": "base_text",
97
+ },
98
+ },
99
+ "configFile": "<path>/fixture/base/config.ts",
100
+ "cwd": "<path>/fixture/base",
101
+ },
102
+ {
103
+ "config": {
104
+ "devConfig": true,
105
+ },
106
+ "configFile": "<path>/fixture/config.dev.ts",
107
+ "cwd": "<path>/fixture",
108
+ },
109
+ {
110
+ "config": {
111
+ "virtual": true,
112
+ },
113
+ },
114
+ ]
115
+ ` )
101
116
} )
102
117
103
118
it ( 'extend from git repo' , async ( ) => {
0 commit comments