Skip to content

fix: eslint jest/no-if in rerender test #465

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions src/__tests__/rerender.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,22 @@ test('rerender will re-render the element', () => {
})

test('hydrate will not update props until next render', () => {
const initial = '<input />'
const initialInputElement = document.createElement('input')
const container = document.createElement('div')
container.appendChild(initialInputElement)
document.body.appendChild(container)

const container = document.body.appendChild(document.createElement('div'))
container.innerHTML = initial
const input = container.querySelector('input')
const firstValue = 'hello'
initialInputElement.value = firstValue

if (!input) throw new Error('No element')
input.value = firstValue
const {rerender} = render(<input value="" onChange={() => null} />, {
container,
hydrate: true,
})

const secondValue = 'goodbye'
expect(initialInputElement.value).toBe(firstValue)

expect(input.value).toBe(firstValue)
const secondValue = 'goodbye'
rerender(<input value={secondValue} onChange={() => null} />)
expect(input.value).toBe(secondValue)
expect(initialInputElement.value).toBe(secondValue)
})