make usage of jest.mock for react-dom conform to defined behavior
Created by: sqs
This helps prepare for using Babel to transpile TypeScript but is good practice regardless.
- In
code_intelligence.test.tsx
, thejest.mock('react-dom', ...)
was rejected with a fatal error by Babel (in babel-jest) because it referred to an out-of-scope variable (for why it rejects this, see https://github.com/facebook/jest/issues/2567). Also, it was undefined behavior that thejest.mock
ofreact-dom
applied to other modules (see "...mocked only for the file that callsjest.mock
..." at https://jestjs.io/docs/en/jest-object#jestmockmodulename-factory-options). So, this commit passes thereact-dom
render
function as an argument to the functions under test to make mocking easier and fully explicit without the need for test harness magic. - Removes unnecessary mocking of
react-dom
intext_fields.test.tsx
. The mock was never checked.
I encountered these problems while trying out Babel 7 for TypeScript transpilation, but fixing them is good practice regardless.