-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add basic smoke tests * style: prettier * style: pretty * fix: add chrome dependencies * bump: node-version * testing * cleanup
- Loading branch information
1 parent
8f7b52c
commit 245a878
Showing
2 changed files
with
51 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const assert = require("assert"); | ||
const puppeteer = require("../lib/engines/puppeteer"); | ||
|
||
describe("PUPPETEER", function() { | ||
this.timeout(5000); | ||
|
||
it("should render a pdf", async () => { | ||
const engine = new puppeteer.Puppeteer(); | ||
await engine.init(); | ||
|
||
const req = { | ||
query: { | ||
url: "https://example.com/", | ||
format: "pdf" | ||
}, | ||
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, "pdf"); | ||
|
||
await engine.destroy(); | ||
}); | ||
|
||
it("should open new page", async () => { | ||
const engine = new puppeteer.Puppeteer(); | ||
await engine.init(); | ||
|
||
await engine._newPage(); | ||
const pages = await engine.instance.pages(); | ||
assert.strictEqual(2, pages.length); | ||
|
||
await engine.destroy(); | ||
}); | ||
}); |