3

This issue says that fireEvent.changeText event should not call onChangeText function when editable is false, yet when I run this:

import React from 'react';
import { fireEvent, render } from '@testing-library/react-native';
import { TextInput } from 'react-native';

describe('Button', () => {
  it('should not be editable, if editable is false', () => {
    const handleChangeText = jest.fn();
    const screen = render(<TextInput onChangeText={ handleChangeText } editable={ false } testID={ 'stuff' }/>);
    fireEvent.changeText(screen.getByTestId('stuff'), 'Trigger');
    expect(handleChangeText).not.toHaveBeenCalled();
  });
});

My test fails, because handleChangeText is called.

I use:

  1. "@testing-library/react-native": "7.1.0"
  2. "react-native": "https://github.com/expo/react-native/archive/sdk-38.0.0.tar.gz"
Petro Ivanenko
  • 637
  • 2
  • 8
  • 19

0 Answers0