@@ -422,12 +422,12 @@ def App():
422422
423423def test_reactjs_component_from_string ():
424424 reactpy .web .reactjs_component_from_string (
425- "temp" , " old" , "Component" , resolve_imports = False
425+ "old" , "Component" , resolve_imports = False , name = "temp"
426426 )
427427 reactpy .web .module ._STRING_WEB_MODULE_CACHE .clear ()
428428 with assert_reactpy_did_log (r"Existing web module .* will be replaced with" ):
429429 reactpy .web .reactjs_component_from_string (
430- "temp" , " new" , "Component" , resolve_imports = False
430+ "new" , "Component" , resolve_imports = False , name = "temp"
431431 )
432432
433433
@@ -452,7 +452,7 @@ def ShowSimpleButton():
452452
453453async def test_reactjs_component_from_file (display : DisplayFixture ):
454454 SimpleButton = reactpy .web .reactjs_component_from_file (
455- "simple-button" , JS_FIXTURES_DIR / "simple-button.js" , "SimpleButton"
455+ JS_FIXTURES_DIR / "simple-button.js" , "SimpleButton" , name = "simple-button "
456456 )
457457
458458 is_clicked = reactpy .Ref (False )
@@ -493,13 +493,13 @@ def test_reactjs_component_from_file_caching(tmp_path):
493493 name = "test-file-module"
494494 reactpy .web .module ._FILE_WEB_MODULE_CACHE .clear ()
495495
496- reactpy .web .reactjs_component_from_file (name , file , "Component" )
496+ reactpy .web .reactjs_component_from_file (file , "Component" , name = name )
497497 key = next (x for x in reactpy .web .module ._FILE_WEB_MODULE_CACHE .keys () if name in x )
498498 module1 = reactpy .web .module ._FILE_WEB_MODULE_CACHE [key ]
499499 assert module1
500500 initial_length = len (reactpy .web .module ._FILE_WEB_MODULE_CACHE )
501501
502- reactpy .web .reactjs_component_from_file (name , file , "Component" )
502+ reactpy .web .reactjs_component_from_file (file , "Component" , name = name )
503503 assert len (reactpy .web .module ._FILE_WEB_MODULE_CACHE ) == initial_length
504504
505505
@@ -508,13 +508,24 @@ def test_reactjs_component_from_string_caching():
508508 content = "export function Component() {}"
509509 reactpy .web .module ._STRING_WEB_MODULE_CACHE .clear ()
510510
511- reactpy .web .reactjs_component_from_string (name , content , "Component" )
511+ reactpy .web .reactjs_component_from_string (content , "Component" , name = name )
512512 key = next (
513513 x for x in reactpy .web .module ._STRING_WEB_MODULE_CACHE .keys () if name in x
514514 )
515515 module1 = reactpy .web .module ._STRING_WEB_MODULE_CACHE [key ]
516516 assert module1
517517 initial_length = len (reactpy .web .module ._STRING_WEB_MODULE_CACHE )
518518
519- reactpy .web .reactjs_component_from_string (name , content , "Component" )
519+ reactpy .web .reactjs_component_from_string (content , "Component" , name = name )
520+ assert len (reactpy .web .module ._STRING_WEB_MODULE_CACHE ) == initial_length
521+
522+
523+ def test_reactjs_component_from_string_with_no_name ():
524+ content = "export function Component() {}"
525+ reactpy .web .module ._STRING_WEB_MODULE_CACHE .clear ()
526+
527+ reactpy .web .reactjs_component_from_string (content , "Component" )
528+ initial_length = len (reactpy .web .module ._STRING_WEB_MODULE_CACHE )
529+
530+ reactpy .web .reactjs_component_from_string (content , "Component" )
520531 assert len (reactpy .web .module ._STRING_WEB_MODULE_CACHE ) == initial_length
0 commit comments