UNPKG

@platformbuilders/react-native-ui

Version:
23 lines 1.11 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 CheckBox from '..'; import { theme } from '../../../test/helpers'; describe('<CheckBox />', () => { it('should render checkbox component', () => { const wrapper = renderer.create(React.createElement(ThemeProvider, { theme: theme }, React.createElement(CheckBox, { id: "testing", accessibility: "" }))); expect(wrapper.toJSON()).toMatchSnapshot(); }); it('should trigger onPress function', () => { const onPressEvent = jest.fn(); const { getByText } = render(React.createElement(ThemeProvider, { theme: theme }, React.createElement(CheckBox, { label: "Jest Checkbox", id: "testing", accessibility: "checkbox", onPress: onPressEvent }))); const component = getByText('Jest Checkbox'); fireEvent.press(component); expect(onPressEvent).toHaveBeenCalled(); }); }); //# sourceMappingURL=CheckBox.spec.js.map