I have a component which renders a select box. When the select box is changed, it calls this.props.select which in turn calls the server via fetch. When this returns it sets the value on the select and loads a bunch of other data.
i've written this unit test
it("updates title when selecting trip", () => {
act(() => {
render(<Trips trips={trips} id={0} select={jest.fn()} save={jest.fn()} savenew={jest.fn()} />, container);
});
act(() => {
userEvent.selectOptions( screen.getByRole('listbox') , '3');
});
expect(screen.getByRole('listbox').value ).toBe('trip3');
})
and it doesn't work, because I'm not changing the value prop. In the future I'm likely to change the select box to a custom select solution so I would actually like to test the basic functionality.
What should I be testing in this situation?
Aucun commentaire:
Enregistrer un commentaire