forked from mwinteringham/restful-booker
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from dgodongm/dg_partialupdate_tests
partial booking update tests
- Loading branch information
Showing
3 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import bookings_generator from "../utils/bookings_generator"; | ||
import bookings_wrapper from "../utils/bookings_wrapper"; | ||
|
||
describe("Update Partial Booking spec", () => { | ||
let temp_token; | ||
|
||
before(() => { | ||
bookings_wrapper.create_auth("admin", "password123").then((response) => { | ||
temp_token = response.body.token; | ||
cy.log("temp_token: " + temp_token); | ||
}); | ||
}); | ||
|
||
it("valid partial update", () => { | ||
let newbooking = bookings_generator.generate_booking(); | ||
const partialbooking = { | ||
firstname: newbooking.firstname + "MODIFIED", | ||
lastname: newbooking.lastname + "MODIFIED", | ||
}; | ||
bookings_wrapper.create_booking(newbooking).then((response) => { | ||
bookings_wrapper | ||
.update_partial_booking(response.body.bookingid, partialbooking, { | ||
token: temp_token, | ||
}) | ||
.then((response) => { | ||
expect(response.status).to.be.equal(200); | ||
expect(response.body.firstname).to.be.deep.equal( | ||
partialbooking.firstname, | ||
); | ||
expect(response.body.lastname).to.be.deep.equal( | ||
partialbooking.lastname, | ||
); | ||
}); | ||
}); | ||
}); | ||
|
||
// this test fails due to API bug. API should return error response and not update, but instead returns 200 and updates booking with invalid value | ||
it.skip("invalid firstname", () => { | ||
let newbooking = bookings_generator.generate_booking(); | ||
const partialbooking = { | ||
firstname: null, | ||
lastname: newbooking.lastname + "MODIFIED", | ||
}; | ||
bookings_wrapper.create_booking(newbooking).then((response) => { | ||
bookings_wrapper | ||
.update_partial_booking(response.body.bookingid, partialbooking, { | ||
token: temp_token, | ||
}) | ||
.then((response) => { | ||
expect(response.status).to.be.equal(400); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters