PliWould/components/__tests__/AreaInput-test.tsx

24 lines
838 B
TypeScript
Raw Normal View History

2024-07-01 15:15:43 +02:00
import React from 'react';
import { render, fireEvent } from '@testing-library/react-native';
import { AreaInput } from '../AreaInput';
describe('AreaInput', () => {
it('renders correctly', () => {
const { getByPlaceholderText } = render(<AreaInput units="foot" />);
const lengthInput = getByPlaceholderText('Length');
const widthInput = getByPlaceholderText('Width');
expect(lengthInput).toBeTruthy();
expect(widthInput).toBeTruthy();
});
it('calls onValueSet when a value is entered', () => {
const onValueSetMock = jest.fn();
const { getByPlaceholderText } = render(
<AreaInput units="foot" onValueSet={onValueSetMock} />
);
const lengthInput = getByPlaceholderText('Length');
fireEvent.changeText(lengthInput, '10');
expect(onValueSetMock).toHaveBeenCalledTimes(1);
});
});