Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React hooks test case part 2 -- useMemo #2144

Merged
merged 1 commit into from
May 29, 2019

Conversation

chenesan
Copy link
Contributor

Related to #2011 .

Add useMemo test cases in both shallow and mount test suites to make sure it works with enzyme. There are 2 tests for each:

  1. In component get memoized value from useMemo and pass it down to child. Then rerender the component by changing a prop which is not in the dependencies of useMemo call. So we can assert that the prop passed down will be the same (===) between two rendering. Note that the memoized value is an object in the test so we can make sure they are shallow equal.
  2. Like (1), but we change a prop which is in dependencies of useMemo, so now the prop passed down will be different between two rendering.
    Any advice on additional tests is welcome :-)

@ljharb ljharb added the Tests label May 29, 2019
@ljharb ljharb merged commit c108326 into enzymejs:master May 29, 2019
@chenesan chenesan deleted the usememo-test branch May 29, 2019 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants