A builder that takes overrides
Test data types must describe the objects the helpers actually create.
your task
Let buildBooking accept any subset of fields, including none. Supplied values must replace defaults. Exclude id from the create request and its type. Use utility types based on Booking. The marked access must be rejected and all cases must pass.
A test supplies new field values, called overrides. The builder ignores them. The create request also contains an id, although the service assigns that field.
Run code does two things. First the compiler checks the types and lists each error with its line. Then your code runs once for each case. A type error does not stop the run. The exercise is solved when there are no type errors and every case passes.
type check
Not run yetbuilder.ts
Expected result: no type errors.
cases
Not run yetDefault booking
Expected output
{"id":1,"room":"Atlas","seats":4,"paid":false}See the input and the code for this case
console.log(buildBooking());
Not run yetNew seats and payment status
Expected output
{"id":1,"room":"Atlas","seats":8,"paid":true}See the input and the code for this case
console.log(buildBooking({ seats: 8, paid: true }));Not run yetCreate request without an id
Expected output
{"room":"Birch","seats":4,"paid":false}See the input and the code for this case
console.log(createPayload(buildBooking({ room: "Birch" })));