feat: add rerender as an alias for update (#149)

<!-- Please provide enough information so that others can review your pull request. -->
<!-- Keep pull requests small and focused on a single change. -->

### Summary

Users of `react-testing-library` use `rerender` wording instead of `update`. Let's make it easier for them by aliasing it.
See: https://testing-library.com/docs/react-testing-library/api#rerender

### Test plan

Added cases for JS tests and TS typings
This commit is contained in:
Michał Pierzchała
2019-04-14 10:09:46 +02:00
committed by Kacper Wiszczuk
parent 488a2ca5cc
commit 439db6c823
5 changed files with 9 additions and 3 deletions
+3 -2
View File
@@ -237,14 +237,15 @@ test('getAllByProp, queryAllByProps', () => {
test('update', () => {
const fn = jest.fn();
const { getByName, update } = render(<Banana onUpdate={fn} />);
const { getByName, update, rerender } = render(<Banana onUpdate={fn} />);
const button = getByName('Button');
button.props.onPress();
update(<Banana onUpdate={fn} />);
rerender(<Banana onUpdate={fn} />);
expect(fn).toHaveBeenCalledTimes(2);
expect(fn).toHaveBeenCalledTimes(3);
});
test('unmount', () => {
+1
View File
@@ -27,6 +27,7 @@ export default function render(
...getByAPI(instance),
...queryByAPI(instance),
update: updateWithAct(renderer),
rerender: updateWithAct(renderer), // alias for `update`
unmount: renderer.unmount,
toJSON: renderer.toJSON,
debug: debug(instance, renderer),