Skip to content

Commit

Permalink
tests: adding should render a PNG by default test case
Browse files Browse the repository at this point in the history
  • Loading branch information
hugo-gomes committed Feb 29, 2024
1 parent 6c11b89 commit c58d89e
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/engines/puppeteer.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,38 @@ describe("Puppeteer", function() {
}
});

it("should render a PNG by default", async () => {
const engine = new puppeteer.Puppeteer();
await engine.init();

try {
const req = {
query: {
url: "https://example.com/"
},
body: {}
};
const res = {
send: function(data) {
this.data = data;
},
type: function(file) {
this.file = file;
}
};
await engine.render(req, res);
assert.ok(res.data);
assert.strictEqual(res.file, "png");
assert.ok(
res.data
.slice(0, 8)
.equals(Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]))
);
} finally {
await engine.destroy();
}
});

it("should render a PNG", async () => {
const engine = new puppeteer.Puppeteer();
await engine.init();
Expand Down

0 comments on commit c58d89e

Please sign in to comment.