@@ -187,34 +187,43 @@ describe("ProtectedZoneSceneObject", () => {
187187
188188 instance [ "handleContactPenalty" ] ( redRobotBodyId , blueRobotBodyId )
189189
190- expect ( vi . mocked ( SimulationSystem . robotPenalty ) ) . toHaveBeenCalledTimes ( 1 )
191- expect ( vi . mocked ( SimulationSystem . robotPenalty ) ) . toHaveBeenCalledWith ( blueRobot , 5 , expect . any ( String ) )
190+ expect ( vi . mocked ( SimulationSystem . robotPenalty ) ) . toHaveBeenCalledExactlyOnceWith ( blueRobot , 5 , expect . any ( String ) )
192191 } )
193192
194- test ( "HandleContactPenalty opponent robot inside" , ( ) => {
193+ test ( "HandleContactPenalty any robot inside" , ( ) => {
195194 const instance = createProtectedZoneInstance ( {
196- contactType : ContactType . OPPONENT_ROBOT_INSIDE ,
195+ contactType : ContactType . ANY_ROBOT_INSIDE ,
197196 } )
198197
199198 instance [ "zoneCollision" ] ( blueRobotBodyId )
200199
201200 instance [ "handleContactPenalty" ] ( redRobotBodyId , blueRobotBodyId )
202201
203- expect ( vi . mocked ( SimulationSystem . robotPenalty ) ) . toHaveBeenCalledTimes ( 1 )
204- expect ( vi . mocked ( SimulationSystem . robotPenalty ) ) . toHaveBeenCalledWith ( blueRobot , 5 , expect . any ( String ) )
202+ expect ( vi . mocked ( SimulationSystem . robotPenalty ) ) . toHaveBeenCalledExactlyOnceWith ( blueRobot , 5 , expect . any ( String ) )
205203 } )
206204
207- test ( "HandleContactPenalty ally robot inside" , ( ) => {
205+ test ( "HandleContactPenalty blue robot inside" , ( ) => {
208206 const instance = createProtectedZoneInstance ( {
209- contactType : ContactType . ALLY_ROBOT_INSIDE ,
207+ contactType : ContactType . BLUE_ROBOT_INSIDE ,
208+ } )
209+
210+ instance [ "zoneCollision" ] ( blueRobotBodyId )
211+
212+ instance [ "handleContactPenalty" ] ( redRobotBodyId , blueRobotBodyId )
213+
214+ expect ( vi . mocked ( SimulationSystem . robotPenalty ) ) . toHaveBeenCalledExactlyOnceWith ( blueRobot , 5 , expect . any ( String ) )
215+ } )
216+
217+ test ( "HandleContactPenalty red robot inside" , ( ) => {
218+ const instance = createProtectedZoneInstance ( {
219+ contactType : ContactType . RED_ROBOT_INSIDE ,
210220 } )
211221
212222 instance [ "zoneCollision" ] ( redRobotBodyId )
213223
214224 instance [ "handleContactPenalty" ] ( redRobotBodyId , blueRobotBodyId )
215225
216- expect ( vi . mocked ( SimulationSystem . robotPenalty ) ) . toHaveBeenCalledTimes ( 1 )
217- expect ( vi . mocked ( SimulationSystem . robotPenalty ) ) . toHaveBeenCalledWith ( blueRobot , 5 , expect . any ( String ) )
226+ expect ( vi . mocked ( SimulationSystem . robotPenalty ) ) . toHaveBeenCalledExactlyOnceWith ( blueRobot , 5 , expect . any ( String ) )
218227 } )
219228
220229 test ( "HandleContactPenalty doesn't penalize if not all robots are inside" , ( ) => {
@@ -229,9 +238,20 @@ describe("ProtectedZoneSceneObject", () => {
229238 expect ( vi . mocked ( SimulationSystem . robotPenalty ) ) . not . toHaveBeenCalled ( )
230239 } )
231240
232- test ( "HandleContactPenalty doesn't penalize if contact type is ally and ally is not inside" , ( ) => {
241+ test ( "HandleContactPenalty doesn't penalize if contact type is any and no robots are inside" , ( ) => {
242+ const instance = createProtectedZoneInstance ( {
243+ contactType : ContactType . ANY_ROBOT_INSIDE ,
244+ } )
245+
246+
247+ instance [ "handleContactPenalty" ] ( redRobotBodyId , blueRobotBodyId )
248+
249+ expect ( vi . mocked ( SimulationSystem . robotPenalty ) ) . not . toHaveBeenCalled ( )
250+ } )
251+
252+ test ( "HandleContactPenalty doesn't penalize if contact type is red and red is not inside" , ( ) => {
233253 const instance = createProtectedZoneInstance ( {
234- contactType : ContactType . ALLY_ROBOT_INSIDE ,
254+ contactType : ContactType . RED_ROBOT_INSIDE ,
235255 } )
236256
237257 instance [ "zoneCollision" ] ( blueRobotBodyId )
@@ -241,9 +261,9 @@ describe("ProtectedZoneSceneObject", () => {
241261 expect ( vi . mocked ( SimulationSystem . robotPenalty ) ) . not . toHaveBeenCalled ( )
242262 } )
243263
244- test ( "HandleContactPenalty doesn't penalize if contact type is opponent and opponent is not inside" , ( ) => {
264+ test ( "HandleContactPenalty doesn't penalize if contact type is blue and blue is not inside" , ( ) => {
245265 const instance = createProtectedZoneInstance ( {
246- contactType : ContactType . OPPONENT_ROBOT_INSIDE ,
266+ contactType : ContactType . BLUE_ROBOT_INSIDE ,
247267 } )
248268
249269 instance [ "zoneCollision" ] ( redRobotBodyId )
0 commit comments