@@ -386,6 +386,7 @@ describe("setBackgroundColor", () => {
386386 turtles . _scale = 1.0 ;
387387 global . platformColor = { background : "#ffffff" } ;
388388 turtles . _backgroundColor = platformColor . background ;
389+ turtles . makeBackground = jest . fn ( ) ;
389390 } ) ;
390391
391392 test ( "should set default background color when index is -1" , ( ) => {
@@ -409,22 +410,10 @@ describe("setBackgroundColor", () => {
409410 expect ( activityMock . refreshCanvas ) . toHaveBeenCalled ( ) ;
410411 } ) ;
411412
412- test ( "should update DOM body background color" , ( ) => {
413+ test ( "should keep background color in sync with internal state " , ( ) => {
413414 turtles . setBackgroundColor ( - 1 ) ;
414415
415- // jsdom normalizes hex colors to rgb format
416- const bgColor = document . body . style . backgroundColor ;
417- expect ( bgColor === platformColor . background || bgColor === "rgb(255, 255, 255)" ) . toBe ( true ) ;
418- } ) ;
419-
420- test ( "should update canvas background color" , ( ) => {
421- turtles . setBackgroundColor ( - 1 ) ;
422-
423- // Canvas style object is a plain object, not a DOM style, so it keeps the original value
424- const canvasBg = activityMock . canvas . style . backgroundColor ;
425- expect ( canvasBg === platformColor . background || canvasBg === "rgb(255, 255, 255)" ) . toBe (
426- true
427- ) ;
416+ expect ( turtles . _backgroundColor ) . toBe ( platformColor . background ) ;
428417 } ) ;
429418} ) ;
430419
@@ -451,6 +440,7 @@ describe("doScale", () => {
451440 turtles . _locked = false ;
452441 turtles . _queue = [ ] ;
453442 turtles . _backgroundColor = "#ffffff" ;
443+ turtles . makeBackground = jest . fn ( ) ;
454444 } ) ;
455445
456446 test ( "should update scale, width, and height when not locked" , ( ) => {
0 commit comments