- Mastering React Test:Driven Development
- Daniel Irvine
- 98字
- 2021-06-24 14:45:10
Finishing off the form with a submit button
It's a good time to add a submit button and perform a manual test to check what you've created. A submit button test is relatively simple. Add the following test to your test file:
it('has a submit button', () => {
render(<CustomerForm />);
const submitButton = container.querySelector(
'input[type="submit"]'
);
expect(submitButton).not.toBeNull();
});
Then, make that pass by adding in your submit button into the form, at the bottom:
<form id="customer" onSubmit={handleSubmit}>
...
<input type="submit" value="Add" />
</form>
Update your entrypoint in src/index.js to render a new CustomerForm instance, rather than an AppointmentsDayView, and you should be ready to manually test:

推薦閱讀
- INSTANT OpenCV Starter
- 垃圾回收的算法與實現
- PostgreSQL Cookbook
- 華為HMS生態與應用開發實戰
- 編程珠璣(續)
- R語言游戲數據分析與挖掘
- Learning Bayesian Models with R
- Full-Stack React Projects
- SSM輕量級框架應用實戰
- Hands-On Full Stack Development with Go
- Webpack實戰:入門、進階與調優
- 智能搜索和推薦系統:原理、算法與應用
- 零基礎學HTML+CSS
- Moodle 3 Administration(Third Edition)
- Python Programming for Arduino