这个问题说fireEvent.changeText
事件不应该在is时调用onChangeText
函数,但是当我运行它时:editable
false
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();
});
});
我的测试失败了,因为handleChangeText
被调用了。
我用:
"@testing-library/react-native": "7.1.0"
"react-native": "https://github.com/expo/react-native/archive/sdk-38.0.0.tar.gz"