Skip to content

Instantly share code, notes, and snippets.

@tanner-west
Created April 27, 2022 20:51
Show Gist options
  • Save tanner-west/dcd15b6e7bdf09bcc69577fbb6b70d40 to your computer and use it in GitHub Desktop.
Save tanner-west/dcd15b6e7bdf09bcc69577fbb6b70d40 to your computer and use it in GitHub Desktop.
import React from 'react';
import {fireEvent, render} from '@testing-library/react-native';
import Name from './Name';
describe('<Name />', () => {
let getByText: any, getByTestId: any;
beforeEach(() => {
({getByText, getByTestId} = render(<Name />));
});
it("should render 'get started' message", () => {
getByText('Please type your name to get started');
});
it("should render 'Your name is: Ray Bradbury'", () => {
const nameInput = getByTestId('name-input');
fireEvent(nameInput, 'onChangeText', 'Ray Bradbury');
getByText('Your name is: Ray Bradbury');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment