D
D
Dmitry2019-06-12 22:35:25
JavaScript
Dmitry, 2019-06-12 22:35:25

Testing Enzyme.. Why is the data not updated after simulate()?

I am testing a react component using Enzyme
The component has an array of 150 records displayed in a table
Pagination of 50 records is used, respectively, only the first 50 are displayed in the table
First they are sorted by guest name

const component = mount(<GuestsList />)
const guestNames = component.find('.cell-guestName') 
// Показывается все верно, length: 50 (Anna April, Anna Astray...)

Now I want to change the sort to descending and simulate a click on the column
component.find('th.column-guestName').sumulate('click')

I look in the component.html() debugger, everything is rendered correctly, I see 50 lines with names in descending order (Rebecca Stanford, Rebecca Red...)
However
const guestNames = component.find('.cell-guestName')

still the same, length: 50 (Anna April, Anna Astray...)
As if html and object search live different lives. How to synchronize them?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question