@@ -124,6 +124,94 @@ it.each([
124124 expect ( result2 . config ) . toEqual ( {
125125 value : 'two' ,
126126 } )
127+
128+ // Test config with default and named exports simultaneously
129+ await writeFile ( configPath , `export const config = {
130+ value: 'three',
131+ }
132+ export default config` , 'utf8' )
133+
134+ const result3 = await loadConfig ( {
135+ sources : [ { files : configFileName } ] ,
136+ cwd,
137+ } )
138+
139+ expect ( result3 . config ) . toEqual ( {
140+ value : 'three' ,
141+ } )
142+
143+ // Test config with several named exports only
144+ await writeFile ( configPath , `export const config1 = {
145+ value1: 'config-1',
146+ }
147+ export const config2= {
148+ value2: 'config-2',
149+ }` , 'utf8' )
150+
151+ const result4 = await loadConfig ( {
152+ sources : [ { files : configFileName } ] ,
153+ cwd,
154+ } )
155+
156+ expect ( result4 . config ) . toEqual ( {
157+ config1 : {
158+ value1 : 'config-1' ,
159+ } ,
160+ config2 : {
161+ value2 : 'config-2' ,
162+ } ,
163+ } )
164+
165+ // Test config with default and several named exports simultaneously
166+ await writeFile ( configPath , `export const config1 = {
167+ value1: 'config-1',
168+ }
169+ export const config2= {
170+ value2: 'config-2',
171+ }
172+ export const config3= {
173+ value3: 'config-3',
174+ }
175+ export default config3` , 'utf8' )
176+
177+ const result5 = await loadConfig ( {
178+ sources : [ { files : configFileName } ] ,
179+ cwd,
180+ } )
181+
182+ expect ( result5 . config ) . toEqual ( {
183+ config1 : {
184+ value1 : 'config-1' ,
185+ } ,
186+ config2 : {
187+ value2 : 'config-2' ,
188+ } ,
189+ value3 : 'config-3' ,
190+ } )
191+
192+ // Test config when default export property and named export itself have similar names
193+ await writeFile ( configPath , `export const config1 = {
194+ value1: 'config-1',
195+ }
196+ export const config2= {
197+ value2: 'config-2',
198+ }
199+ export const config3= {
200+ config1: 'config-3',
201+ }
202+ export default config3` , 'utf8' )
203+
204+ const result6 = await loadConfig ( {
205+ sources : [ { files : configFileName } ] ,
206+ cwd,
207+ } )
208+
209+ expect ( result6 . config ) . toEqual ( {
210+ config1 : 'config-3' ,
211+ config2 : {
212+ value2 : 'config-2' ,
213+ } ,
214+ } )
127215} )
128216
129217it ( 'custom parser' , async ( ) => {
0 commit comments