mirror of
https://github.com/jellyfin/jellyfin-expo.git
synced 2024-11-23 14:09:41 +00:00
Add test for ButtonListItem
This commit is contained in:
parent
b3478e81af
commit
d56f69dbb8
@ -3,10 +3,10 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
import React from 'react';
|
||||
import { StyleSheet } from 'react-native';
|
||||
import { Button, ListItem } from 'react-native-elements';
|
||||
import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
import { StyleSheet } from 'react-native';
|
||||
|
||||
const ButtonListItem = ({ item, index }) => (
|
||||
<ListItem
|
||||
@ -15,6 +15,7 @@ const ButtonListItem = ({ item, index }) => (
|
||||
>
|
||||
<ListItem.Content>
|
||||
<Button
|
||||
testID='button'
|
||||
{...item}
|
||||
type='clear'
|
||||
buttonStyle={{ ...styles.button, ...item.buttonStyle }}
|
||||
|
32
components/__tests__/ButtonListItem.test.js
Normal file
32
components/__tests__/ButtonListItem.test.js
Normal file
@ -0,0 +1,32 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
import { fireEvent, render } from '@testing-library/react-native';
|
||||
import React from 'react';
|
||||
|
||||
import ButtonListItem from '../ButtonListItem';
|
||||
|
||||
describe('ButtonListItem', () => {
|
||||
it('should render correctly and handle presses', () => {
|
||||
const onPress = jest.fn();
|
||||
|
||||
const { getByTestId } = render(
|
||||
<ButtonListItem
|
||||
index={0}
|
||||
item={{
|
||||
title: 'Test Button',
|
||||
onPress
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
const button = getByTestId('button');
|
||||
expect(button).toHaveTextContent('Test Button');
|
||||
|
||||
expect(onPress).not.toHaveBeenCalled();
|
||||
fireEvent.press(button);
|
||||
expect(onPress).toHaveBeenCalled();
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user