Skip to content

React hooks test case part 2 -- useMemo#2144

Merged
ljharb merged 1 commit into
enzymejs:masterfrom
chenesan:usememo-test
May 29, 2019
Merged

React hooks test case part 2 -- useMemo#2144
ljharb merged 1 commit into
enzymejs:masterfrom
chenesan:usememo-test

Conversation

@chenesan

Copy link
Copy Markdown
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