This repository has been archived by the owner on Oct 3, 2020. It is now read-only.
-
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 #24 from UoGSOCIS/19-exec-path-id
19 exec path
- Loading branch information
Showing
3 changed files
with
75 additions
and
5 deletions.
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
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 |
---|---|---|
|
@@ -301,6 +301,22 @@ suite("APIv1 exec routes", function() { | |
}); | ||
}); | ||
|
||
test("a valid exec object, wong content type", function() { | ||
return request(app) | ||
.post("/api/v1/execs") | ||
.set("Content-Type", "x-www-form-urlencoded") | ||
.set("Authorization", `Bearer ${userToken}`) | ||
.send("name=test user1") | ||
.send("[email protected]") | ||
.send("order=2") | ||
.send("year=2019") | ||
.send("role=admin") | ||
.expect(statusCodes.BAD_REQUEST) | ||
.then((res) => { | ||
check.api["v1"].isGenericResponse(statusCodes.BAD_REQUEST, res.body); | ||
}); | ||
}); | ||
|
||
test("a valid object and an invalid object", function() { | ||
|
||
return request(app) | ||
|
@@ -496,7 +512,24 @@ suite("APIv1 exec routes", function() { | |
}); | ||
}); | ||
|
||
test("update an exec that does not exist in the db", function() { | ||
test("update a single exec, wong content type", function() { | ||
return request(app) | ||
.patch("/api/v1/execs") | ||
.set("Content-Type", "x-www-form-urlencoded") | ||
.set("Authorization", `Bearer ${userToken}`) | ||
.send("id=5ccf449cd0c3a1ac66636b64") | ||
.send("name=test user1") | ||
.send("[email protected]") | ||
.send("order=2") | ||
.send("year=2019") | ||
.send("role=admin") | ||
.expect(statusCodes.BAD_REQUEST) | ||
.then((res) => { | ||
check.api["v1"].isGenericResponse(statusCodes.BAD_REQUEST, res.body); | ||
}); | ||
}); | ||
|
||
test("update an exec that does not exist in the db, valid format", function() { | ||
let update1 = JSON.parse(JSON.stringify(pres1)); | ||
|
||
update1.id = "5ccf449cd0c3a1ac66636b64"; | ||
|
@@ -511,6 +544,21 @@ suite("APIv1 exec routes", function() { | |
}); | ||
}); | ||
|
||
test("update an exec that does not exist in the db,invalid format", function() { | ||
let update1 = JSON.parse(JSON.stringify(pres1)); | ||
|
||
update1.id = "execId"; | ||
return request(app) | ||
.patch("/api/v1/execs") | ||
.set("Content-Type", "application/json") | ||
.set("Authorization", `Bearer ${userToken}`) | ||
.send([update1]) | ||
.expect(statusCodes.BAD_REQUEST) | ||
.then((res) => { | ||
check.api["v1"].isGenericResponse(statusCodes.BAD_REQUEST, res.body); | ||
}); | ||
}); | ||
|
||
test("missing authentication", function() { | ||
|
||
let update1 = JSON.parse(JSON.stringify(pres1)); | ||
|
@@ -684,7 +732,7 @@ suite("APIv1 exec routes", function() { | |
}); | ||
}); | ||
|
||
test("deleting non existent exec", function() { | ||
test("deleting non existent exec, correct id format", function() { | ||
return request(app) | ||
.delete("/api/v1/execs/5ccf7ab78caf96e09f00ab22") | ||
.set("Authorization", `Bearer ${userToken}`) | ||
|
@@ -693,6 +741,16 @@ suite("APIv1 exec routes", function() { | |
check.api["v1"].isGenericResponse(statusCodes.NOT_FOUND, res.body); | ||
}); | ||
}); | ||
|
||
test("deleting non existent exec, bad id format", function() { | ||
return request(app) | ||
.delete("/api/v1/execs/execId") | ||
.set("Authorization", `Bearer ${userToken}`) | ||
.expect(statusCodes.NOT_FOUND) | ||
.then((res) => { | ||
check.api["v1"].isGenericResponse(statusCodes.NOT_FOUND, res.body); | ||
}); | ||
}); | ||
|
||
test("deleting an exec that has already been deleted", function () { | ||
return request(app) | ||
|