Last active
July 20, 2020 15:46
-
-
Save livando/6bac7b57a4e8e098469511a43dd0ddf5 to your computer and use it in GitHub Desktop.
Basic React Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://reactjs.org/docs/testing-recipes.html | |
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import { act } from 'react-dom/test-utils'; | |
import NewComment from '../NewComment'; | |
let div = document.createElement('div'); | |
beforeEach(() => { | |
div = document.createElement('div'); | |
document.body.appendChild(div); | |
}); | |
afterEach(() => { | |
ReactDOM.unmountComponentAtNode(div); | |
div.remove(); | |
div = null; | |
}); | |
describe('Popup for initial comment', () => { | |
it('has a link to post', () => { | |
act(() => { | |
ReactDOM.render(<NewComment />, div); | |
}); | |
const firstLink = div.querySelector('a'); | |
expect(firstLink.text).toEqual('post'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment