我正在使用 react-native-testing-library - https://callstack.github.io/react-native-testing-library/docs/getting-started
我有一个<SegmentedControlIOS>
- https://facebook.github.io/react-native/docs/segmentedcontrolios
我要讲第一段。我正在这样做:
const testID = "SegmentedControl";
const stub = jest.fn();
const values = [{ label: "foo" }];
const { getByTestId } = render(
<SegmentedControlIOS values={['foo', 'bar']} onChange={stub} testID={testID} />
);
expect(() => {
getByTestId(testID);
}).not.toThrow();
fireEvent(getByTestId(testID), "change ", {
nativeEvent: {
value: values[0],
selectedSegmentIndex: 0,
},
});
但是我得到了错误:
No handler function found for event: "change "
截图如下。有人知道如何按不同的段<SegmentedControlIOS>
吗?