-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeleteClientTestScript.js
64 lines (60 loc) · 2.32 KB
/
deleteClientTestScript.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Set the base URL for the API
pm.environment.set("baseUrl", "http://localhost:5000")
// Test case 1: Try to delete a client that exists
pm.test("Delete an existing client", function () {
// Send a DELETE request to the API to delete the client with ID 1
pm.sendRequest({
url: pm.environment.get("baseUrl") + "/client/2008",
method: "DELETE",
headers: {
"Content-Type": "application/json"
}
}, function (err, res) {
// Check if the response has a status code of 200
//pm.expect(res.status).to.equal(OK);
pm.expect(res).to.have.status(200);
//pm.expect(res.json().error).to.eql("Client deleted successfully");
});
});
// Test case 2: Try to delete a client that doesn't exist
pm.test("Delete a non-existing client", function () {
// Send a DELETE request to the API to delete a client with an invalid ID
pm.sendRequest({
url: pm.environment.get("baseUrl") + "/client/1000",
method: "DELETE",
headers: {
"Content-Type": "application/json"
}
}, function (err, res) {
// Check if the response has a status code of 404
pm.expect(res).to.have.status(404);
});
});
// Test case 3: Try to delete a client with an invalid ID
pm.test("Delete a client with invalid ID", function () {
// Send a DELETE request to the API to delete a client with an invalid ID
pm.sendRequest({
url: pm.environment.get("baseUrl") + "/client/abc",
method: "DELETE",
headers: {
"Content-Type": "application/json"
}
}, function (err, res) {
// Check if the response has a status code of 404
pm.expect(res).to.have.status("Not Found");
});
});
// Test case 4: Try to delete a client without specifying the ID
pm.test("Delete a client without specifying ID", function () {
// Send a DELETE request to the API without specifying the ID of the client to delete
pm.sendRequest({
url: pm.environment.get("baseUrl") + "/client/",
method: "DELETE",
headers: {
"Content-Type": "application/json"
}
}, function (err, res) {
// Check if the response has a status code of 404
pm.expect(res.status).to.equal("Not Found");
});
});