@@ -108,6 +108,17 @@ describe('mount', () => {
108
108
} )
109
109
110
110
describe ( 'for svg' , ( ) => {
111
+ it ( 'renders foreignObject and sets dimensions' , ( ) => {
112
+ render (
113
+ < svg >
114
+ < foreignObject x = "50" y = "100" width = "150" height = "200" />
115
+ </ svg > ,
116
+ )
117
+ expect ( root ?. innerHTML ?? '' ) . toBe (
118
+ '<svg><foreignObject height="200" x="50" width="150" y="100"></foreignObject></svg>' ,
119
+ )
120
+ } )
121
+
111
122
it ( 'sets the d' , ( ) => {
112
123
render ( < fast-path d = "M0,0 L0,10 Z" /> )
113
124
expect ( root ?. innerHTML ?? '' ) . toBe ( '<path d="M0,0 L0,10 Z"></path>' )
@@ -497,6 +508,22 @@ describe('mount', () => {
497
508
} )
498
509
499
510
describe ( 'for svg' , ( ) => {
511
+ it ( 'renders foreignObject and sets dimensions' , ( ) => {
512
+ const xFacet = createFacet ( { initialValue : '50' } )
513
+ const yFacet = createFacet ( { initialValue : '100' } )
514
+ const widthFacet = createFacet ( { initialValue : '150' } )
515
+ const heightFacet = createFacet ( { initialValue : '200' } )
516
+
517
+ render (
518
+ < svg >
519
+ < fast-foreignObject x = { xFacet } y = { yFacet } width = { widthFacet } height = { heightFacet } />
520
+ </ svg > ,
521
+ )
522
+ expect ( root ?. innerHTML ?? '' ) . toBe (
523
+ '<svg><foreignObject height="200" x="50" width="150" y="100"></foreignObject></svg>' ,
524
+ )
525
+ } )
526
+
500
527
it ( 'sets the d' , ( ) => {
501
528
const dFacet = createFacet ( { initialValue : 'M0,0 L0,10 Z' } )
502
529
@@ -1239,6 +1266,48 @@ describe('update', () => {
1239
1266
} )
1240
1267
1241
1268
describe ( 'for svg' , ( ) => {
1269
+ it ( 'updates foreignObject dimensions' , ( ) => {
1270
+ const MockComponent = ( ) => {
1271
+ const [ xFacet , setXFacet ] = useState < string | undefined > ( '50' )
1272
+ const [ yFacet , setYFacet ] = useState < string | undefined > ( '100' )
1273
+ const [ widthFacet , setWidthFacet ] = useState < string | undefined > ( '150' )
1274
+ const [ heightFacet , setHeightFacet ] = useState < string | undefined > ( '200' )
1275
+
1276
+ useEffect ( ( ) => {
1277
+ setTimeout ( ( ) => setXFacet ( '350' ) , 1 )
1278
+ setTimeout ( ( ) => setYFacet ( '400' ) , 2 )
1279
+ setTimeout ( ( ) => setWidthFacet ( '450' ) , 3 )
1280
+ setTimeout ( ( ) => setHeightFacet ( '500' ) , 4 )
1281
+ } , [ ] )
1282
+ return (
1283
+ < svg >
1284
+ < fast-foreignObject x = { xFacet } y = { yFacet } width = { widthFacet } height = { heightFacet } />
1285
+ </ svg >
1286
+ )
1287
+ }
1288
+
1289
+ render ( < MockComponent /> )
1290
+ expect ( root ?. innerHTML ?? '' ) . toBe (
1291
+ '<svg><foreignObject height="200" x="50" width="150" y="100"></foreignObject></svg>' ,
1292
+ )
1293
+ jest . advanceTimersByTime ( 1 )
1294
+ expect ( root ?. innerHTML ?? '' ) . toBe (
1295
+ '<svg><foreignObject height="200" x="350" width="150" y="100"></foreignObject></svg>' ,
1296
+ )
1297
+ jest . advanceTimersByTime ( 1 )
1298
+ expect ( root ?. innerHTML ?? '' ) . toBe (
1299
+ '<svg><foreignObject height="200" x="350" width="150" y="400"></foreignObject></svg>' ,
1300
+ )
1301
+ jest . advanceTimersByTime ( 1 )
1302
+ expect ( root ?. innerHTML ?? '' ) . toBe (
1303
+ '<svg><foreignObject height="200" x="350" width="450" y="400"></foreignObject></svg>' ,
1304
+ )
1305
+ jest . advanceTimersByTime ( 1 )
1306
+ expect ( root ?. innerHTML ?? '' ) . toBe (
1307
+ '<svg><foreignObject height="500" x="350" width="450" y="400"></foreignObject></svg>' ,
1308
+ )
1309
+ } )
1310
+
1242
1311
it ( 'updates d' , ( ) => {
1243
1312
const MockComponent = ( ) => {
1244
1313
const [ d , setD ] = useState < string | undefined > ( 'M0,0 L0,10 Z' )
0 commit comments