@@ -354,4 +354,57 @@ describe('copyConfigKeyEntry', () => {
354354 await expect ( fileExists ( joinPath ( outDir , 'tools.json' ) ) ) . resolves . toBe ( true )
355355 } )
356356 } )
357+
358+ describe ( 'value guard' , ( ) => {
359+ test ( 'throws when value is an empty string' , async ( ) => {
360+ await inTemporaryDirectory ( async ( tmpDir ) => {
361+ const outDir = joinPath ( tmpDir , 'out' )
362+ await mkdir ( outDir )
363+ const context = makeContext ( { assets : '' } )
364+ const promise = copyConfigKeyEntry ( {
365+ key : 'assets' ,
366+ baseDir : tmpDir ,
367+ outputDir : outDir ,
368+ context,
369+ appDirectory : tmpDir ,
370+ } )
371+ await expect ( promise ) . rejects . toThrow ( AbortError )
372+ await expect ( promise ) . rejects . toThrow ( `'assets' can't be empty.` )
373+ } )
374+ } )
375+
376+ test ( 'throws when value is whitespace-only' , async ( ) => {
377+ await inTemporaryDirectory ( async ( tmpDir ) => {
378+ const outDir = joinPath ( tmpDir , 'out' )
379+ await mkdir ( outDir )
380+ const context = makeContext ( { assets : ' ' } )
381+ const promise = copyConfigKeyEntry ( {
382+ key : 'assets' ,
383+ baseDir : tmpDir ,
384+ outputDir : outDir ,
385+ context,
386+ appDirectory : tmpDir ,
387+ } )
388+ await expect ( promise ) . rejects . toThrow ( AbortError )
389+ await expect ( promise ) . rejects . toThrow ( `'assets' can't be empty.` )
390+ } )
391+ } )
392+
393+ test ( 'throws with the full configKey when the key is nested' , async ( ) => {
394+ await inTemporaryDirectory ( async ( tmpDir ) => {
395+ const outDir = joinPath ( tmpDir , 'out' )
396+ await mkdir ( outDir )
397+ const context = makeContext ( { extension_points : [ { assets : '' } ] } )
398+ const promise = copyConfigKeyEntry ( {
399+ key : 'extension_points[].assets' ,
400+ baseDir : tmpDir ,
401+ outputDir : outDir ,
402+ context,
403+ appDirectory : tmpDir ,
404+ } )
405+ await expect ( promise ) . rejects . toThrow ( AbortError )
406+ await expect ( promise ) . rejects . toThrow ( `'extension_points[].assets' can't be empty.` )
407+ } )
408+ } )
409+ } )
357410} )
0 commit comments