@@ -159,10 +159,7 @@ describe('node constants', () => {
159159 it ( 'should check minor version for Node.js 22' , ( ) => {
160160 const major = getNodeMajorVersion ( )
161161 if ( major === 22 ) {
162- const minor = Number . parseInt (
163- process . version . split ( '.' ) [ 1 ] || '0' ,
164- 10 ,
165- )
162+ const minor = Number . parseInt ( process . version . split ( '.' ) [ 1 ] || '0' , 10 )
166163 const result = supportsNodeRequireModule ( )
167164 if ( minor >= 12 ) {
168165 expect ( result ) . toBe ( true )
@@ -190,10 +187,7 @@ describe('node constants', () => {
190187 it ( 'should check minor version for Node.js 22' , ( ) => {
191188 const major = getNodeMajorVersion ( )
192189 if ( major === 22 ) {
193- const minor = Number . parseInt (
194- process . version . split ( '.' ) [ 1 ] || '0' ,
195- 10 ,
196- )
190+ const minor = Number . parseInt ( process . version . split ( '.' ) [ 1 ] || '0' , 10 )
197191 const result = supportsNodeRun ( )
198192 if ( minor >= 11 ) {
199193 expect ( result ) . toBe ( true )
@@ -437,4 +431,102 @@ describe('node constants', () => {
437431 expect ( ESNEXT ) . toBe ( 'esnext' )
438432 } )
439433 } )
434+
435+ describe ( 'edge cases and comprehensive coverage' , ( ) => {
436+ it ( 'should handle all flag getters being called multiple times' , ( ) => {
437+ // Call each getter multiple times to ensure caching works
438+ for ( let i = 0 ; i < 3 ; i ++ ) {
439+ getNodeDebugFlags ( )
440+ getNodeHardenFlags ( )
441+ getNodePermissionFlags ( )
442+ getNodeNoWarningsFlags ( )
443+ getNodeDisableSigusr1Flags ( )
444+ }
445+ } )
446+
447+ it ( 'should verify all flag arrays are non-empty or conditionally empty' , ( ) => {
448+ const debugFlags = getNodeDebugFlags ( )
449+ const hardenFlags = getNodeHardenFlags ( )
450+ const noWarningsFlags = getNodeNoWarningsFlags ( )
451+ const sigusr1Flags = getNodeDisableSigusr1Flags ( )
452+
453+ expect ( debugFlags . length ) . toBeGreaterThan ( 0 )
454+ expect ( hardenFlags . length ) . toBeGreaterThan ( 0 )
455+ expect ( noWarningsFlags . length ) . toBeGreaterThan ( 0 )
456+ expect ( sigusr1Flags . length ) . toBeGreaterThan ( 0 )
457+
458+ // Permission flags are conditionally empty for Node < 24
459+ const permissionFlags = getNodePermissionFlags ( )
460+ const major = getNodeMajorVersion ( )
461+ if ( major >= 24 ) {
462+ expect ( permissionFlags . length ) . toBeGreaterThan ( 0 )
463+ } else {
464+ expect ( permissionFlags . length ) . toBe ( 0 )
465+ }
466+ } )
467+
468+ it ( 'should verify maintained versions caching' , ( ) => {
469+ const v1 = getMaintainedNodeVersions ( )
470+ const v2 = getMaintainedNodeVersions ( )
471+ const v3 = getMaintainedNodeVersions ( )
472+ expect ( v1 ) . toBe ( v2 )
473+ expect ( v2 ) . toBe ( v3 )
474+ } )
475+
476+ it ( 'should verify all support functions return boolean' , ( ) => {
477+ expect ( typeof supportsNodeCompileCacheApi ( ) ) . toBe ( 'boolean' )
478+ expect ( typeof supportsNodeCompileCacheEnvVar ( ) ) . toBe ( 'boolean' )
479+ expect ( typeof supportsNodeDisableWarningFlag ( ) ) . toBe ( 'boolean' )
480+ expect ( typeof supportsNodePermissionFlag ( ) ) . toBe ( 'boolean' )
481+ expect ( typeof supportsNodeRequireModule ( ) ) . toBe ( 'boolean' )
482+ expect ( typeof supportsNodeRun ( ) ) . toBe ( 'boolean' )
483+ expect ( typeof supportsNodeDisableSigusr1Flag ( ) ) . toBe ( 'boolean' )
484+ expect ( typeof supportsProcessSend ( ) ) . toBe ( 'boolean' )
485+ } )
486+
487+ it ( 'should verify version string format' , ( ) => {
488+ const version = getNodeVersion ( )
489+ expect ( version ) . toMatch ( / ^ v \d + \. \d + \. \d + / )
490+ expect ( version . startsWith ( 'v' ) ) . toBe ( true )
491+ } )
492+
493+ it ( 'should verify major version is positive integer' , ( ) => {
494+ const major = getNodeMajorVersion ( )
495+ expect ( Number . isInteger ( major ) ) . toBe ( true )
496+ expect ( major ) . toBeGreaterThan ( 0 )
497+ } )
498+
499+ it ( 'should verify execPath is absolute path' , ( ) => {
500+ const execPath = getExecPath ( )
501+ expect ( execPath ) . toBeTruthy ( )
502+ expect ( typeof execPath ) . toBe ( 'string' )
503+ expect ( execPath . length ) . toBeGreaterThan ( 0 )
504+ } )
505+
506+ it ( 'should verify flag contents are strings starting with --' , ( ) => {
507+ const allFlags = [
508+ ...getNodeDebugFlags ( ) ,
509+ ...getNodeHardenFlags ( ) ,
510+ ...getNodePermissionFlags ( ) ,
511+ ...getNodeNoWarningsFlags ( ) ,
512+ ...getNodeDisableSigusr1Flags ( ) ,
513+ ]
514+
515+ allFlags . forEach ( flag => {
516+ expect ( typeof flag ) . toBe ( 'string' )
517+ expect ( flag . startsWith ( '--' ) ) . toBe ( true )
518+ } )
519+ } )
520+
521+ it ( 'should verify constants are exportable and accessible' , ( ) => {
522+ // Verify constants can be destructured and used
523+ const seaFuse = NODE_SEA_FUSE
524+ const esnext = ESNEXT
525+
526+ expect ( seaFuse ) . toBeDefined ( )
527+ expect ( esnext ) . toBeDefined ( )
528+ expect ( typeof seaFuse ) . toBe ( 'string' )
529+ expect ( typeof esnext ) . toBe ( 'string' )
530+ } )
531+ } )
440532} )
0 commit comments