vendredi 21 février 2020

How to i check if state is changed in a react test?

I am very new to testing in React. I update the state at the end of my sort function. I just can figure out how to get the state from the Wrapper I am creating.

test('Sorting Data No Change', () => {
   const wrapper = shallow(render(<Table headers={[
                       {name:"ID", prop: "id"},
                       {name:"Manufacturer", prop: "manufacturer"},
                       {name:"Model", prop: "model"}
                       ]}
              data={data}
              bold ="Ford"
              upper="Model" />);


        );


  console.log(wrapper.instance().sort("asend", "id"));
  expect(wrapper.state.filtered).equals(data);
});

Aucun commentaire:

Enregistrer un commentaire