Skip to content

Instantly share code, notes, and snippets.

@tanner-west
Created April 13, 2022 18:51
Show Gist options
  • Save tanner-west/6f9c334fa1ea42a30e376b30010c534c to your computer and use it in GitHub Desktop.
Save tanner-west/6f9c334fa1ea42a30e376b30010c534c to your computer and use it in GitHub Desktop.
describe('<MyInteractiveComponent/>', () => {
it('should update Name label when input is changed', () => {
// For a <TextInput />, use onChangeText()
const editNameInput = getByA11yLabel(wrapper, 'edit-name-input');
editNameInput.props().onChangeText('Billy Budd');
const name = getByA11yLabel(wrapper, 'name-text');
expect(name.props().children).toEqual('Billy Budd');
});
it('should update Favorite Century label when picker input is changed', () => {
// For a <Picker />, use onValueChange()
const centuryPicker = getByTestId(wrapper, 'century-picker');
centuryPicker.props().onValueChange('Nineteenth');
const name = getByA11yLabel(wrapper, 'century-text');
expect(name.props().children).toEqual('Nineteenth');
});
it('should open modal when button is pressed', () => {
// For a <Button />, use onPress()
const openModalButton = getByTestId(wrapper, 'open-modal-button');
openModalButton.props().onPress();
const modal = getByTestId(wrapper, 'modal');
expect(modal.props().isVisible).toEqual(true);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment