@@ -468,27 +468,48 @@ describe('scanFile - Pattern Detection', () => {
468468 }
469469
470470 it ( 'returns two patterns for a given alias' , ( ) => {
471- const patterns = buildSveltekitAliasPatterns ( 'privateEnv' ) ;
471+ const patterns = buildSveltekitAliasPatterns (
472+ 'privateEnv' ,
473+ '$env/dynamic/private' ,
474+ ) ;
472475 expect ( patterns ) . toHaveLength ( 2 ) ;
473476 expect ( patterns [ 0 ] ?. regex ) . toBeInstanceOf ( RegExp ) ;
474477 expect ( patterns [ 1 ] ?. regex ) . toBeInstanceOf ( RegExp ) ;
475478 expect ( patterns . every ( ( p ) => p . name === 'sveltekit' ) ) . toBe ( true ) ;
476479 } ) ;
477480
481+ it ( 'sets sourceModule on both returned patterns' , ( ) => {
482+ const patterns = buildSveltekitAliasPatterns (
483+ 'privateEnv' ,
484+ '$env/dynamic/private' ,
485+ ) ;
486+ expect ( patterns [ 0 ] ?. sourceModule ) . toBe ( '$env/dynamic/private' ) ;
487+ expect ( patterns [ 1 ] ?. sourceModule ) . toBe ( '$env/dynamic/private' ) ;
488+ } ) ;
489+
478490 it ( 'dot notation pattern matches alias.VAR' , ( ) => {
479- const [ dotPattern ] = buildSveltekitAliasPatterns ( 'privateEnv' ) ;
491+ const [ dotPattern ] = buildSveltekitAliasPatterns (
492+ 'privateEnv' ,
493+ '$env/dynamic/private' ,
494+ ) ;
480495 expect ( dotPattern ! . regex . test ( 'privateEnv.MY_SECRET' ) ) . toBe ( true ) ;
481496 expect ( dotPattern ! . regex . test ( 'env.MY_SECRET' ) ) . toBe ( false ) ;
482497 } ) ;
483498
484499 it ( 'destructuring processor returns [] for empty content (if !content branch)' , ( ) => {
485- const [ , destructurePattern ] = buildSveltekitAliasPatterns ( 'privateEnv' ) ;
500+ const [ , destructurePattern ] = buildSveltekitAliasPatterns (
501+ 'privateEnv' ,
502+ '$env/dynamic/private' ,
503+ ) ;
486504 const result = destructurePattern ! . processor ! ( makeMatch ( '{}' , '' ) ) ;
487505 expect ( result ) . toEqual ( [ ] ) ;
488506 } ) ;
489507
490508 it ( 'destructuring processor returns [] when content is undefined' , ( ) => {
491- const [ , destructurePattern ] = buildSveltekitAliasPatterns ( 'privateEnv' ) ;
509+ const [ , destructurePattern ] = buildSveltekitAliasPatterns (
510+ 'privateEnv' ,
511+ '$env/dynamic/private' ,
512+ ) ;
492513 const result = destructurePattern ! . processor ! ( makeMatch ( '{}' , undefined ) ) ;
493514 expect ( result ) . toEqual ( [ ] ) ;
494515 } ) ;
0 commit comments