UNPKG

@platformbuilders/react-native-ui

Version:
23 lines 1.16 kB
import 'jest'; import React from 'react'; import renderer from 'react-test-renderer'; import { render, fireEvent } from 'react-native-testing-library'; import { ThemeProvider } from 'styled-components/native'; import RadioButton from '..'; import { theme } from '../../../test/helpers'; describe('<RadioButton />', () => { it('should render radio button component', () => { const wrapper = renderer.create(React.createElement(ThemeProvider, { theme: theme }, React.createElement(RadioButton, { id: "testing_radio_btn", accessibility: "Select information" }))); expect(wrapper.toJSON()).toMatchSnapshot(); }); it('should trigger onPress function', () => { const onPressEvent = jest.fn(); const { getByTestId } = render(React.createElement(ThemeProvider, { theme: theme }, React.createElement(RadioButton, { id: "testing_radio_btn", accessibility: "checkbox", onPress: onPressEvent }))); const component = getByTestId('testing_radio_btn'); fireEvent.press(component); expect(onPressEvent).toHaveBeenCalled(); }); }); //# sourceMappingURL=RadioButton.spec.js.map