Mastering React Test-Driven Development - Second Edition by Daniel Irvine

Mastering React Test-Driven Development - Second Edition by Daniel Irvine

Author:Daniel Irvine
Language: eng
Format: epub, mobi
Publisher: Packt Publishing Pvt. Ltd.
Published: 2022-09-15T00:00:00+00:00


In test/CustomerForm.test.js, update the import that contains blankCustomer, pulling in the new validCustomer too:import {

blankCustomer,

validCustomer,

} from "./builders/customer";

Starting at the top, modify each test that simulates a submit event. Each should be mounted with this new validCustomer object. After making these changes, run your tests and make sure they are still passing before continuing:render(<CustomerForm original={validCustomer} />);

Add a new test for submitting the form. This can go alongside the other submit tests, rather than in the validation block:it("does not submit the form when there are validation errors", async () => {

render(<CustomerForm original={blankCustomer} />);

await clickAndWait(submitButton());

expect(global.fetch).not.toBeCalled();

});



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.