@@ -55,11 +55,15 @@ func TestWatchHandler_Enable_Success(t *testing.T) {
5555
5656 tc .WatchService .EXPECT ().IsWatching ().Return (false )
5757 tc .ScrollService .EXPECT ().GetDir ().Return ("/path/to/scroll" )
58- // When request has no body or empty body, BodyParser fails, so SetHotReloadCommands is NOT called
59- tc .WatchService .EXPECT ().StartWatching ("/path/to/scroll" , gomock .Any (), gomock .Any ()).Return (nil )
58+ tc .WatchService .EXPECT ().StartWatching ("/path/to/scroll" , "src" , "config" ).Return (nil )
6059 tc .WatchService .EXPECT ().IsWatching ().Return (true )
6160
62- req := httptest .NewRequest ("POST" , "/api/v1/watch/enable" , nil )
61+ requestBody := api.WatchModeRequest {
62+ WatchPaths : []string {"src" , "config" },
63+ }
64+ bodyBytes , _ := json .Marshal (requestBody )
65+
66+ req := httptest .NewRequest ("POST" , "/api/v1/watch/enable" , bytes .NewReader (bodyBytes ))
6367 req .Header .Set ("Content-Type" , "application/json" )
6468 resp , err := tc .App .Test (req )
6569 if err != nil {
@@ -143,10 +147,15 @@ func TestWatchHandler_Enable_StartWatchingError(t *testing.T) {
143147
144148 tc .WatchService .EXPECT ().IsWatching ().Return (false )
145149 tc .ScrollService .EXPECT ().GetDir ().Return ("/path/to/scroll" )
146- // When request has no body, BodyParser fails, so SetHotReloadCommands is NOT called
147- tc .WatchService .EXPECT ().StartWatching ("/path/to/scroll" , gomock .Any (), gomock .Any ()).Return (fiber .NewError (500 , "watcher error" ))
150+ tc .WatchService .EXPECT ().StartWatching ("/path/to/scroll" , "src" ).Return (fiber .NewError (500 , "watcher error" ))
148151
149- req := httptest .NewRequest ("POST" , "/api/v1/watch/enable" , nil )
152+ requestBody := api.WatchModeRequest {
153+ WatchPaths : []string {"src" },
154+ }
155+ bodyBytes , _ := json .Marshal (requestBody )
156+
157+ req := httptest .NewRequest ("POST" , "/api/v1/watch/enable" , bytes .NewReader (bodyBytes ))
158+ req .Header .Set ("Content-Type" , "application/json" )
150159 resp , err := tc .App .Test (req )
151160 if err != nil {
152161 t .Fatalf ("Failed to execute request: %v" , err )
@@ -165,12 +174,13 @@ func TestWatchHandler_Enable_WithCommands(t *testing.T) {
165174 tc .WatchService .EXPECT ().IsWatching ().Return (false )
166175 tc .ScrollService .EXPECT ().GetDir ().Return ("/path/to/scroll" )
167176 tc .WatchService .EXPECT ().SetHotReloadCommands ([]string {"npm run dev" })
168- tc .WatchService .EXPECT ().StartWatching ("/path/to/scroll" , gomock . Any (), gomock . Any () ).Return (nil )
177+ tc .WatchService .EXPECT ().StartWatching ("/path/to/scroll" , "src" , "lib" ).Return (nil )
169178 tc .WatchService .EXPECT ().IsWatching ().Return (true )
170179
171180 hotReloadCmds := []string {"npm run dev" }
172181 requestBody := api.WatchModeRequest {
173182 HotReloadCommands : & hotReloadCmds ,
183+ WatchPaths : []string {"src" , "lib" },
174184 }
175185 bodyBytes , _ := json .Marshal (requestBody )
176186
0 commit comments