fix: Two API endpoints where requesting a permenantly deleted document results in server error

This commit is contained in:
Tom Moor
2020-09-08 07:29:06 -07:00
parent b1648ac2aa
commit f264d67862
2 changed files with 26 additions and 1 deletions

View File

@ -185,6 +185,15 @@ describe("#documents.info", () => {
expect(body.data.id).toEqual(document.id);
});
it("should not error if document doesn't exist", async () => {
const user = await buildUser();
const res = await server.post("/api/documents.info", {
body: { token: user.getJwtToken(), id: "test" },
});
expect(res.status).toEqual(404);
});
it("should require authorization without token", async () => {
const { document } = await seed();
const res = await server.post("/api/documents.info", {
@ -1309,6 +1318,15 @@ describe("#documents.restore", () => {
expect(res.status).toEqual(403);
});
it("should not error if document doesn't exist", async () => {
const user = await buildUser();
const res = await server.post("/api/documents.restore", {
body: { token: user.getJwtToken(), id: "test" },
});
expect(res.status).toEqual(404);
});
it("should require authentication", async () => {
const res = await server.post("/api/documents.restore");
const body = await res.json();