Fakultas Ilmu Komputer UI

Commit 6aaf01d4 authored by Bagus Prabowo's avatar Bagus Prabowo Committed by angelin depthios
Browse files

Feature: Arrowless Plain button

parent 3164556e
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import React from "react";
import { cleanup, render } from "@testing-library/react-native";
import ArrowlessPlainButton from "../../button/ArrowlessPlainButton";
afterEach(cleanup);
const ArrowlessWrapper = () => {
return <ArrowlessPlainButton content="Test" onPress={() => {}} />;
};
describe("Arrowless Plain Button Test", () => {
it("Should detect a touchable component", () => {
const { getByTestId } = render(<ArrowlessWrapper />);
expect(getByTestId("Touchable")).not.toBeNull();
});
it("Should detect a view component", () => {
const { getByTestId } = render(<ArrowlessWrapper />);
expect(getByTestId("View")).not.toBeNull();
});
it("Should detect a text component", () => {
const { getByTestId } = render(<ArrowlessWrapper />);
expect(getByTestId("Text")).not.toBeNull();
});
});
import React from "react";
import { StyleSheet, TouchableOpacity, Text, View } from "react-native";
import Colors from "../../constants/Colors";
type props = {
content: string;
onPress: () => void;
};
const ArrowlessPlainButton = ({ content = "", onPress }: props) => {
return (
<TouchableOpacity
style={styles.touchableContainer}
onPress={() => onPress()}
testID="Touchable"
>
<View style={styles.textContainer} testID="View">
<Text style={styles.content} testID="Text">
{content}
</Text>
</View>
</TouchableOpacity>
);
};
const styles = StyleSheet.create({
touchableContainer: {
width: "100%",
},
textContainer: {
backgroundColor: Colors.background,
borderColor: Colors.form.filled.border,
borderWidth: 1,
borderRadius: 8,
height: 52,
justifyContent: "center",
},
content: {
color: Colors.text.subtitle,
fontSize: 14,
paddingHorizontal: 8,
fontWeight: "300",
},
});
export default ArrowlessPlainButton;
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