Skip to content

Commit 7a7647f

Browse files
rvdkooyKent C. Dodds
authored and
Kent C. Dodds
committed
chore: fixed the eslint jest/no-if error by not needing the if statement anymore (#465)
1 parent c4e51fb commit 7a7647f

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/__tests__/rerender.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,22 @@ test('rerender will re-render the element', () => {
1010
})
1111

1212
test('hydrate will not update props until next render', () => {
13-
const initial = '<input />'
13+
const initialInputElement = document.createElement('input')
14+
const container = document.createElement('div')
15+
container.appendChild(initialInputElement)
16+
document.body.appendChild(container)
1417

15-
const container = document.body.appendChild(document.createElement('div'))
16-
container.innerHTML = initial
17-
const input = container.querySelector('input')
1818
const firstValue = 'hello'
19+
initialInputElement.value = firstValue
1920

20-
if (!input) throw new Error('No element')
21-
input.value = firstValue
2221
const {rerender} = render(<input value="" onChange={() => null} />, {
2322
container,
2423
hydrate: true,
2524
})
2625

27-
const secondValue = 'goodbye'
26+
expect(initialInputElement.value).toBe(firstValue)
2827

29-
expect(input.value).toBe(firstValue)
28+
const secondValue = 'goodbye'
3029
rerender(<input value={secondValue} onChange={() => null} />)
31-
expect(input.value).toBe(secondValue)
30+
expect(initialInputElement.value).toBe(secondValue)
3231
})

0 commit comments

Comments
 (0)