/** @jsxImportSource test */ import { RefObject, useRef } from "react"; import { FlatList, View } from "react-native"; import { getOpaqueStyles, registerCSS, remapProps, render, resetComponents, screen, } from "test"; import { PLACEHOLDER_SYMBOL, StyleRuleSetSymbol, StyleRuleSymbol, } from "../shared"; const testID = "react-native-css-interop"; beforeEach(() => { resetComponents(); }); test("mapping", () => { remapProps(View as any, { className: "differentStyle" }); registerCSS( `.bg-black { background-color: black } .text-white { color: white }`, ); render(); const component = screen.getByTestId(testID); expect(component.props).toEqual({ testID, differentStyle: { [PLACEHOLDER_SYMBOL]: true, }, }); expect(getOpaqueStyles(component.props.differentStyle)).toStrictEqual([ { [StyleRuleSetSymbol]: true, n: [ { [StyleRuleSymbol]: true, d: [ [ { backgroundColor: "#000000", }, ], ], s: [1, 1], }, ], }, { [StyleRuleSetSymbol]: true, n: [ { [StyleRuleSymbol]: true, d: [ [ { color: "#ffffff", }, ], ], s: [2, 1], }, ], }, ]); }); test("works with ref", () => { remapProps(FlatList, {}); let listRef: RefObject> = { current: null }; const items = Array.from(Array(100).keys()); const Component = () => { listRef = useRef(null); return ( i.toString()} renderItem={(_) => } /> ); }; render(); expect(listRef.current).toBeInstanceOf(FlatList); });