Skip to content

Commit

Permalink
Add smoke test
Browse files Browse the repository at this point in the history
  • Loading branch information
rmehner committed Jan 30, 2023
1 parent 222ffd0 commit 225f7e6
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/smoke.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { describe, expect, it } from "vitest";

import build from "../app";
const app = build();

describe("Smoke tests", () => {
it("sends the PDF on the success case", async () => {
const response = await app.inject({
method: "POST",
url: "/pdf",
payload: { url: "https://coding-robin.de" },
});

expect(response.payload.startsWith("%PDF")).toBeTruthy();
});

it("returns an error object when the page could not be loaded", async () => {
const response = await app.inject({
method: "POST",
url: "/pdf",
payload: {
url: "http://httpbin.org/status/404",
},
});

expect(response.statusCode).toEqual(404);
const error = JSON.parse(response.body);

expect(error).toMatchObject({
error: true,
status: 404,
statusText: "NOT FOUND",
message: "",
});
});
});

0 comments on commit 225f7e6

Please sign in to comment.