@@ -42,6 +42,26 @@ describe("Text", async () => {
42
42
expect ( label . enableWrapping ) . to . eq ( true ) ;
43
43
} ) ;
44
44
45
+ it ( "get bounds" , ( ) => {
46
+ const textWithoutCanvas = root . addComponent ( Text ) ;
47
+ textWithoutCanvas . text = "hello world" ;
48
+ const bounds = textWithoutCanvas . bounds ;
49
+ expect ( bounds . min ) . to . deep . include ( { x : - 50 , y : - 50 , z : 0 } ) ;
50
+ expect ( bounds . max ) . to . deep . include ( { x : 50 , y : 50 , z : 0 } ) ;
51
+
52
+ const labelBounds = label . bounds ;
53
+ expect ( labelBounds . min ) . to . deep . include ( { x : - 50 , y : - 50 , z : 0 } ) ;
54
+ expect ( labelBounds . max ) . to . deep . include ( { x : 50 , y : 50 , z : 0 } ) ;
55
+ label . text = "hello world" ;
56
+ const labelBounds2 = label . bounds ;
57
+ expect ( labelBounds2 . min ) . to . deep . include ( { x : - 50 , y : - 50 , z : 0 } ) ;
58
+ expect ( labelBounds2 . max ) . to . deep . include ( { x : 50 , y : 50 , z : 0 } ) ;
59
+ ( < UITransform > label . entity . transform ) . size . x = 200 ;
60
+ const labelBounds3 = label . bounds ;
61
+ expect ( labelBounds3 . min ) . to . deep . include ( { x : - 100 , y : - 50 , z : 0 } ) ;
62
+ expect ( labelBounds3 . max ) . to . deep . include ( { x : 100 , y : 50 , z : 0 } ) ;
63
+ } ) ;
64
+
45
65
it ( "emoji" , ( ) => {
46
66
const textEntity = canvasEntity . createChild ( "text" ) ;
47
67
0 commit comments