From 252e14d98ce87804604bbf7e1f73b6a0fe46caef Mon Sep 17 00:00:00 2001 From: Sjaak Schilperoort Date: Wed, 25 Oct 2023 18:08:01 +0200 Subject: [PATCH] Add pressIn handler to LargeButton component --- src/components/LargeButton.tsx | 3 +++ src/components/__tests__/LargeButton.test.tsx | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/src/components/LargeButton.tsx b/src/components/LargeButton.tsx index fb516d5..4b2a960 100644 --- a/src/components/LargeButton.tsx +++ b/src/components/LargeButton.tsx @@ -12,6 +12,7 @@ import theme from '../styles/theme' type LargeButtonProps = { title: string onPress?: () => void + onPressIn?: () => void iconName?: IconName disabled?: boolean secondary?: boolean @@ -51,6 +52,7 @@ const LargeButton = ({ title, iconName, onPress, + onPressIn, testID = 'touchable-opacity', }: LargeButtonProps) => { const { textStyle, buttonStyle, iconColor } = getStyle(secondary, disabled, danger) @@ -61,6 +63,7 @@ const LargeButton = ({ style={[styles.container, style, buttonStyle]} disabled={disabled} onPress={onPress} + onPressIn={onPressIn} activeOpacity={0.5} > diff --git a/src/components/__tests__/LargeButton.test.tsx b/src/components/__tests__/LargeButton.test.tsx index c69ffa9..d9acd18 100644 --- a/src/components/__tests__/LargeButton.test.tsx +++ b/src/components/__tests__/LargeButton.test.tsx @@ -5,6 +5,7 @@ import { render, fireEvent } from '@testing-library/react-native' import LargeButton from '../LargeButton' const onPress = jest.fn() +const onPressIn = jest.fn() describe('LargeButton', () => { test('Rendering, enabled, primary', () => { @@ -51,4 +52,12 @@ describe('LargeButton', () => { await fireEvent.press(getByTestId('touchable-opacity')) expect(onPress).toBeCalled() }) + + test('onPressIn', async () => { + const { getByTestId } = render( + , + ) + await fireEvent(getByTestId('touchable-opacity'), 'pressIn') + expect(onPressIn).toBeCalled() + }) })