Skip to content
This repository was archived by the owner on Jul 30, 2020. It is now read-only.

Update the example on this repository readme file #42

Closed
smakosh opened this issue Jul 16, 2019 · 3 comments
Closed

Update the example on this repository readme file #42

smakosh opened this issue Jul 16, 2019 · 3 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed released

Comments

@smakosh
Copy link
Contributor

smakosh commented Jul 16, 2019

Details

The example on this repository's readme file isn't working, but the one on the docs is working fine, it would be helpful to have the same example in order for the new comers not get frustrated that the example isn't working.

import React from 'react';
import { Button, Text, TextInput, View } from 'react-native';
import { fireEvent, render, wait } from '@testing-library/react-native';

function Example() {
  const [name, setUser] = React.useState('');
  const [show, setShow] = React.useState(false);

  return (
    <View>
      <TextInput value={name} onChangeText={setUser} testID="input" />
      <Button
        title="Print Username"
        onPress={() => {
          // let's pretend this is making a server request, so it's async
          // (you'd want to mock this imaginary request in your unit tests)...
          setTimeout(() => {
            setShow(!show);
          }, Math.floor(Math.random() * 200));
        }}
      />
      {show && <Text testID="printed-username">{name}</Text>}
    </View>
  );
}

test('examples of some things', async () => {
  const { getByTestId, getByText, queryByTestId, baseElement } = render(<Example />);
  const famousWomanInHistory = 'Ada Lovelace';

  const input = getByTestId('input');
  fireEvent.changeText(input, famousWomanInHistory);

  const button = getByText('Print Username');
  fireEvent.press(button);

  await wait(() => expect(queryByTestId('printed-username')).toBeTruthy());

  expect(getByTestId('printed-username').props.children).toBe(famousWomanInHistory);
  expect(baseElement).toMatchSnapshot();
});
@bcarroll22
Copy link
Collaborator

Ah sorry for the inconvenience. Would you be able to submit a pull request to update the example in the repo's readme? Thanks!

@bcarroll22 bcarroll22 added good first issue Good for newcomers help wanted Extra attention is needed labels Jul 16, 2019
@smakosh
Copy link
Contributor Author

smakosh commented Jul 16, 2019

Sure

@bcarroll22
Copy link
Collaborator

🎉 This issue has been resolved in version 4.0.8 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers help wanted Extra attention is needed released
Projects
None yet
Development

No branches or pull requests

2 participants