/** @jsxImportSource nativewind */
import { View } from "react-native";
import { fireEvent, render, screen } from "../test";
const grandparentID = "grandparentID";
const parentID = "parent";
const childID = "child";
test("Styling based on parent state (group-{modifier})", async () => {
await render(
,
);
const parent = screen.getByTestId(parentID);
const child = screen.getByTestId(childID);
expect(parent).toHaveStyle(undefined);
expect(child).toHaveStyle(undefined);
fireEvent(parent, "hoverIn");
expect(child).toHaveStyle({ color: "#ffffff" });
});
test("Differentiating nested groups", async () => {
await render(
,
);
const grandparent = screen.getByTestId(grandparentID);
const parent = screen.getByTestId(parentID);
const child = screen.getByTestId(childID);
expect(grandparent).toHaveStyle(undefined);
expect(parent).toHaveStyle(undefined);
expect(child).toHaveStyle(undefined);
fireEvent(grandparent, "hoverIn");
expect(child).toHaveStyle(undefined);
fireEvent(parent, "hoverIn");
expect(child).toHaveStyle({ color: "#ffffff" });
});
test("arbitrary groups - single className", async () => {
const { rerender } = await render(
,
);
const parent = screen.getByTestId(parentID);
const child = screen.getByTestId(childID);
expect(parent).toHaveStyle(undefined);
expect(child).toHaveStyle(undefined);
await rerender(
,
);
expect(child).toHaveStyle({ color: "#ffffff" });
});
test("arbitrary groups - multiple className", async () => {
const { rerender } = await render(
,
);
const parent = screen.getByTestId(parentID);
const child = screen.getByTestId(childID);
expect(parent).toHaveStyle(undefined);
expect(child).toHaveStyle(undefined);
await rerender(
,
);
expect(parent).toHaveStyle(undefined);
expect(child).toHaveStyle(undefined);
await rerender(
,
);
expect(child).toHaveStyle({ color: "#ffffff" });
});
test("arbitrary groups - props", async () => {
const { rerender } = await render(
,
);
const parent = screen.getByTestId(parentID);
const child = screen.getByTestId(childID);
expect(parent).toHaveStyle(undefined);
expect(child).toHaveStyle(undefined);
await rerender(
,
);
expect(child).toHaveStyle({ color: "#ffffff" });
});