@@ -129,6 +129,30 @@ describe("Shape : RoundRect", () => {
129129 const rr = new RoundRect ( 0 , 0 , 30 , 50 , 100 ) ;
130130 expect ( rr . radius ) . toEqual ( 15 ) ; // 30/2
131131 } ) ;
132+
133+ it ( "should clamp radius when width shrinks via setter" , ( ) => {
134+ const rr = new RoundRect ( 0 , 0 , 100 , 100 , 40 ) ;
135+ rr . width = 20 ;
136+ expect ( rr . radius ) . toEqual ( 10 ) ; // clamped to 20/2
137+ } ) ;
138+
139+ it ( "should clamp radius when height shrinks via setter" , ( ) => {
140+ const rr = new RoundRect ( 0 , 0 , 100 , 100 , 40 ) ;
141+ rr . height = 30 ;
142+ expect ( rr . radius ) . toEqual ( 15 ) ; // clamped to 30/2
143+ } ) ;
144+
145+ it ( "should clamp negative radius to 0" , ( ) => {
146+ const rr = new RoundRect ( 0 , 0 , 100 , 100 , - 10 ) ;
147+ expect ( rr . radius ) . toEqual ( 0 ) ;
148+ } ) ;
149+
150+ it ( "should clamp negative radius to 0 via setter" , ( ) => {
151+ const rr = new RoundRect ( 0 , 0 , 100 , 100 , 20 ) ;
152+ rr . radius = - 5 ;
153+ expect ( rr . radius ) . toEqual ( 0 ) ;
154+ expect ( rr . points . length ) . toEqual ( 4 ) ; // plain rectangle
155+ } ) ;
132156 } ) ;
133157
134158 describe ( "contains — corner edge cases" , ( ) => {
@@ -226,6 +250,17 @@ describe("Shape : RoundRect", () => {
226250 it ( "should contain itself" , ( ) => {
227251 expect ( rrect . containsRectangle ( rrect ) ) . toEqual ( true ) ;
228252 } ) ;
253+
254+ it ( "should accept a Rect (not just RoundRect)" , ( ) => {
255+ const inner = new Rect ( 90 , 90 , 20 , 20 ) ;
256+ expect ( rrect . containsRectangle ( inner ) ) . toEqual ( true ) ;
257+ } ) ;
258+
259+ it ( "should accept any object with left/right/top/bottom" , ( ) => {
260+ expect (
261+ rrect . containsRectangle ( { left : 90 , right : 110 , top : 90 , bottom : 110 } ) ,
262+ ) . toEqual ( true ) ;
263+ } ) ;
229264 } ) ;
230265
231266 describe ( "copy, clone & equality — additional cases" , ( ) => {
0 commit comments