In order to implement this test case, we will add code which takes care of the following:
- Defines dummy data for a post and an auth object
- Mocks auth-helper.js
- Defines the test and within the test definition
- Declares the post and auth variables
- Sets the return value of the mocked isAuthenticated method to the dummy auth object
- Uses renderer.create to create the Post component with the required dummy props passed and wrapped in MemoryRouter to provide the props related to react-router
- Generates and matches snapshots
The code in post.test.js to incorporate the steps described for this specific test will be as follows:
import auth from './../auth/auth-helper.js'import Post from './../post/Post.js'import React from 'react' ...