react-native-svg Color Prop Testing

65 Views Asked by At

I'm currently using react-native-svg and the SvgXml component like this:

<SvgXml
    xml={ iconXml }
    color={ "#DF2530" }
    height={ 22 }
    width={ 22 }
    testID="testId"
/>

When I'm doing my tests using jest and the toHaveProp, the color is being converted to 4292814128. I would assume that it's just a decimal color, but when I convert the hex using parseInt("DF2530", 16) I get 14624048 which is way off.

How do I test that the color is the expected one? E.g, the below is what I was expecting.

const iconSvg = getByTestId("testId");
expect(iconSvg).toHaveProp("color", "#DF2530");

but I'm getting the below:

    Expected the element to have prop:
      color=14624048
    Received:
      color=4292814128
0

There are 0 best solutions below