@@ -437,27 +437,51 @@ function runTests({ mode }: TestConfig) {
437437 } ) ;
438438
439439 it ( 'should keep callback runtime wiring out of component sources' , ( ) => {
440- const remoteClientCounterSource = fs . readFileSync (
441- path . join ( remoteDir , 'src/components/RemoteClientCounter.tsx' ) ,
442- 'utf-8' ,
440+ const getFilesRecursively = ( directory : string ) : string [ ] =>
441+ fs . readdirSync ( directory , { withFileTypes : true } ) . flatMap ( entry => {
442+ const entryPath = path . join ( directory , entry . name ) ;
443+ if ( entry . isDirectory ( ) ) {
444+ return getFilesRecursively ( entryPath ) ;
445+ }
446+ return [ entryPath ] ;
447+ } ) ;
448+
449+ const componentFilePaths = getFilesRecursively (
450+ path . join ( remoteDir , 'src/components' ) ,
443451 ) ;
444- const remoteClientBadgeSource = fs . readFileSync (
445- path . join ( remoteDir , 'src/components/RemoteClientBadge.tsx' ) ,
446- 'utf-8' ,
452+ const exposeRuntimeFilePaths = getFilesRecursively (
453+ path . join ( remoteDir , 'src/runtime/exposes' ) ,
454+ ) ;
455+
456+ const componentSources = componentFilePaths . map ( filePath =>
457+ fs . readFileSync ( filePath , 'utf-8' ) ,
447458 ) ;
448459 const runtimeInitSource = fs . readFileSync (
449460 path . join ( remoteDir , 'src/runtime/initServerCallback.ts' ) ,
450461 'utf-8' ,
451462 ) ;
452- expect ( remoteClientCounterSource ) . not . toContain ( 'initServerCallback' ) ;
453- expect ( remoteClientCounterSource ) . not . toContain (
454- 'registerRemoteServerCallback' ,
455- ) ;
456- expect ( remoteClientBadgeSource ) . not . toContain ( 'initServerCallback' ) ;
457- expect ( remoteClientBadgeSource ) . not . toContain (
458- 'registerRemoteServerCallback' ,
463+ const runtimeRegisterSource = fs . readFileSync (
464+ path . join ( remoteDir , 'src/runtime/registerServerCallback.ts' ) ,
465+ 'utf-8' ,
459466 ) ;
467+
468+ expect (
469+ componentSources . every (
470+ source => ! source . includes ( 'initServerCallback' ) ,
471+ ) ,
472+ ) . toBe ( true ) ;
473+ expect (
474+ componentSources . every (
475+ source => ! source . includes ( 'registerRemoteServerCallback' ) ,
476+ ) ,
477+ ) . toBe ( true ) ;
478+ expect (
479+ exposeRuntimeFilePaths . every ( filePath =>
480+ fs . readFileSync ( filePath , 'utf-8' ) . includes ( 'initServerCallback' ) ,
481+ ) ,
482+ ) . toBe ( true ) ;
460483 expect ( runtimeInitSource ) . toContain ( 'registerRemoteServerCallback' ) ;
484+ expect ( runtimeRegisterSource ) . toContain ( 'setServerCallback' ) ;
461485 } ) ;
462486
463487 it ( 'should not load callback helper expose chunk' , ( ) => {
0 commit comments