May 2019
Intermediate to advanced
496 pages
10h 38m
English
React offers a mechanism for setting default prop values, defaultProps, which will be used when required props are not explicitly provided.
Just below the definition of the AppointmentForm function in src/AppointmentForm.js, add the following:
AppointmentForm.defaultProps = { selectableServices: [ 'Cut', 'Blow-dry', 'Cut & color', 'Beard trim', 'Cut & beard trim', 'Extensions']};
We didn't write a test for this code. Doesn't this break our rule of never writing code without first having a failing test? No. In our unit tests, we only test-drive behavior, not static data. A test to prove that defaultProps has the values we expect would simply be duplicating the array list.
Testing static data does ...
Read now
Unlock full access