11import { render , screen } from '@testing-library/react-native' ;
22import { EaseText } from '../EaseText' ;
33
4+ function getTextColor ( text : ReturnType < typeof screen . getByText > ) {
5+ const flatStyle = Array . isArray ( text . props . style )
6+ ? Object . assign ( { } , ...text . props . style . filter ( Boolean ) )
7+ : text . props . style ;
8+ return flatStyle ?. color ;
9+ }
10+
411describe ( 'EaseText' , ( ) => {
512 describe ( 'interpolateColor' , ( ) => {
613 it ( 'applies interpolateColor to Text style' , ( ) => {
714 render ( < EaseText interpolateColor = "#ff0000" > Hello</ EaseText > ) ;
815 const text = screen . getByText ( 'Hello' ) ;
9- const flatStyle = Array . isArray ( text . props . style )
10- ? Object . assign ( { } , ...text . props . style . filter ( Boolean ) )
11- : text . props . style ;
12- expect ( flatStyle . color ) . toBe ( '#ff0000' ) ;
16+ expect ( getTextColor ( text ) ) . toBe ( '#ff0000' ) ;
1317 } ) ;
1418
1519 it ( 'merges interpolateColor with existing style' , ( ) => {
@@ -25,11 +29,26 @@ describe('EaseText', () => {
2529 const flatStyle = Array . isArray ( text . props . style )
2630 ? Object . assign ( { } , ...text . props . style . filter ( Boolean ) )
2731 : text . props . style ;
28- expect ( flatStyle . color ) . toBe ( '#ff0000' ) ;
32+ expect ( getTextColor ( text ) ) . toBe ( '#ff0000' ) ;
2933 expect ( flatStyle . fontSize ) . toBe ( 16 ) ;
3034 expect ( flatStyle . fontWeight ) . toBe ( '600' ) ;
3135 } ) ;
3236
37+ it ( 'does not apply the target color immediately when color is omitted from a transition map' , ( ) => {
38+ render (
39+ < EaseText
40+ interpolateColor = "#ffffff"
41+ initialInterpolateColor = "#000000"
42+ transition = { { transform : { type : 'spring' } } }
43+ >
44+ Hello
45+ </ EaseText > ,
46+ ) ;
47+
48+ const text = screen . getByText ( 'Hello' ) ;
49+ expect ( getTextColor ( text ) ) . toBe ( '#000000' ) ;
50+ } ) ;
51+
3352 it ( 'does not override style when interpolateColor is not set' , ( ) => {
3453 render (
3554 < EaseText style = { { fontSize : 16 , color : '#000' } } > Hello</ EaseText > ,
0 commit comments