Fakultas Ilmu Komputer UI

Commit 1175331d authored by Ahmad Izzudin Alifyandra's avatar Ahmad Izzudin Alifyandra
Browse files

Merge branch 'commentinput' into 'master'

fix the icon form for Comment input

See merge request !156
parents df03ea51 fc03c31d
Pipeline #88942 passed with stage
in 10 minutes and 49 seconds
......@@ -32,7 +32,7 @@ const IconForm = ({
onEndEditing,
}: props) => {
const [isFocused, setIsFocused] = useState(false);
const [showPass, setShowPass] = useState(true);
const [showPass, setShowPass] = useState(type === "password" ? true : false);
const [isError, setIsError] = useState(false);
let backgroundColor: string;
......@@ -56,7 +56,7 @@ const IconForm = ({
const endEdit = () => {
setIsFocused(false);
if (type === "search" || disabled) {
if (type === "search" || disabled || type === "comment") {
setIsError(false);
} else {
if (!validateEmpty(text)) {
......@@ -123,29 +123,29 @@ const IconForm = ({
autoCapitalize={type === "password" ? "none" : "sentences"}
/>
</View>
<TouchableOpacity
onPress={() => type === "password" && setShowPass(!showPass)}
testID="Touchable"
>
{(type === "comment" || type === "search") && (
<TouchableOpacity testID="TouchableIcon" onPress={() => onPress()}>
<MaterialIcons
name={iconName}
size={21}
color={Colors.text.disabled}
testID="MaterialIcon"
/>
</TouchableOpacity>
)}
{!(type === "comment" || type === "search") && (
{type === "password" && (
<TouchableOpacity
onPress={() => type === "password" && setShowPass(!showPass)}
testID="Touchable"
>
<MaterialIcons
name={iconName}
size={21}
color={Colors.text.disabled}
testID="MaterialIcon"
/>
)}
</TouchableOpacity>
</TouchableOpacity>
)}
{(type === "comment" || type === "search") && (
<TouchableOpacity testID="TouchableIcon" onPress={() => onPress()}>
<MaterialIcons
name={iconName}
size={21}
color={Colors.text.disabled}
testID="MaterialIcon"
/>
</TouchableOpacity>
)}
</View>
{isError && (
<View testID="ErrorContainer">
......
......@@ -36,18 +36,21 @@ describe("Icon Form Test", () => {
const { getByTestId } = render(<IconFormWrapper />);
expect(getByTestId("Input")).not.toBeNull();
});
it("Should detect a touchable", () => {
const { getByTestId } = render(<IconFormWrapper />);
expect(getByTestId("Touchable")).not.toBeNull();
});
it("Should detect a MaterialIcon for password", () => {
it("Should detect a touchable for password", () => {
const { getByTestId } = render(<IconFormWrapper type="password" />);
expect(getByTestId("MaterialIcon")).not.toBeNull();
expect(getByTestId("Touchable")).not.toBeNull();
});
it("Should detect a MaterialIcon for search or comment", () => {
it("Should detect a touchable icon for comment", () => {
const { getByTestId } = render(<IconFormWrapper type="comment" />);
expect(getByTestId("MaterialIcon")).not.toBeNull();
});
it("Should detect an onPress function", () => {
const { getByTestId } = render(
<IconFormWrapper type="comment" onPress={() => {}} />
);
fireEvent(getByTestId("TouchableIcon"), "onPress");
expect(getByTestId("TouchableIcon")).not.toBeNull();
});
it("Should not detect a container title", () => {
const { queryByTestId } = render(<IconFormWrapper />);
expect(queryByTestId("TitleContainer")).toBeNull();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment