@@ -91,6 +91,52 @@ class TestComponentRegistry:
9191 def registry (self ):
9292 return ComponentRegistry (maxsize = 2 )
9393
94+ def test_initialize_loads_components (
95+ self , registry , create_bird_template , settings
96+ ):
97+ create_bird_template ("button" , "<button>Click me</button>" )
98+ create_bird_template ("alert" , "<div>Alert</div>" )
99+
100+ registry .discover_components ()
101+
102+ assert "button" in registry ._components
103+ assert "alert" in registry ._components
104+
105+ def test_initialize_loads_assets (
106+ self , registry , create_bird_template , create_bird_asset
107+ ):
108+ template = create_bird_template ("button" , "<button>Click me</button>" )
109+ create_bird_asset (template , ".button { color: red; }" , "css" )
110+ create_bird_asset (template , "console.log('button');" , "js" )
111+
112+ registry .discover_components ()
113+
114+ component = registry ._components ["button" ]
115+ assert len (component .assets ) == 2
116+
117+ def test_initialize_with_custom_dirs (
118+ self , registry , create_bird_template , override_app_settings
119+ ):
120+ create_bird_template (
121+ "button" , "<button>Click me</button>" , bird_dir_name = "components"
122+ )
123+
124+ with override_app_settings (COMPONENT_DIRS = ["components" ]):
125+ registry .discover_components ()
126+
127+ assert "button" in registry ._components
128+
129+ def test_initialize_handles_missing_dirs (self , registry , settings ):
130+ settings .COMPONENT_DIRS = ["nonexistent" ]
131+
132+ registry .discover_components ()
133+
134+ def test_initialize_handles_invalid_components (self , registry , tmp_path , settings ):
135+ component_dir = tmp_path / "bird" / "invalid"
136+ component_dir .mkdir (parents = True )
137+
138+ registry .discover_components ()
139+
94140 def test_get_component_caches (self , registry , create_bird_template ):
95141 create_bird_template (name = "button" , content = "<button>Click me</button>" )
96142
0 commit comments