Skip to content

Select various segments on SegmentedControlIOS #220

@Noitidart

Description

@Noitidart

Ask your Question

I have a <SegmentedControlIOS> - https://facebook.github.io/react-native/docs/segmentedcontrolios

I want to pres the first segment. I am doing this:

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,
  },
});

However I get the error:

No handler function found for event: "change "

Screenshot below. Anyone know how to press different segments in <SegmentedControlIOS>?

enter image description here

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions