import React from "react";
import Input from "./input";
import { fireEvent, render } from "@testing-library/react-native";
import { ThemeProvider } from "../../../theme/src/theme-context";
import Icon from "../../atoms/icon/icon";
jest.useFakeTimers();
describe("Molecules/Input", () => {
it("passes the snapshot test for basic setup", async () => {
const tree = await render(
).toJSON();
expect(tree).toMatchSnapshot();
});
it("passes the snapshot test for different sizes", async () => {
const tree = await render(
).toJSON();
expect(tree).toMatchSnapshot();
});
it("passes the snapshot test for different variants", async () => {
const tree = await render(
).toJSON();
expect(tree).toMatchSnapshot();
});
// it("updates styles correctly when in an error state ", async () => {
// const errorBackgroundColor = "neutral.50";
// const errorBorderColor = "danger.800";
// const { getByTestId } = render(
//
//
//
// );
// const inputContainer = getByTestId("inputFieldContainer");
// expect(inputContainer.props.style.borderColor).toEqual(
// (baseTheme.palette.danger as any)["800"]
// );
// expect(inputContainer.props.style.backgroundColor).toEqual(
// (baseTheme.palette.neutral as any)["50"]
// );
// });
it("passes the snapshot test for different icons", async () => {
const tree = await render(
} />
}
/>
).toJSON();
expect(tree).toMatchSnapshot();
});
it("passes the snapshot test when using style props", async () => {
const tree = await render(
).toJSON();
expect(tree).toMatchSnapshot();
});
it("captures onChangeText event correctly", () => {
const value = "start value";
const onChangeText = jest.fn();
const { getByTestId } = render(
);
const input = getByTestId("inputField");
fireEvent.changeText(input, "new value");
expect(onChangeText).toBeCalledWith("new value");
});
it("doesn't update value when the input is disabled ", async () => {
const onChangeText = jest.fn();
const { getByTestId, queryByText } = await render(
);
const input = getByTestId("inputField");
fireEvent.changeText(input, "new value");
expect(queryByText("new value")).toBeNull();
});
});