From f1f78a5bbd39f7a71701aa0a86077f133264d129 Mon Sep 17 00:00:00 2001 From: Marc Bachmann Date: Wed, 22 Mar 2017 11:11:55 -0400 Subject: [PATCH] Add test for http cookie support --- test/index.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/index.js b/test/index.js index ace1a5f..a48b42e 100644 --- a/test/index.js +++ b/test/index.js @@ -222,3 +222,36 @@ test('load external js', function (t) { t.assert(fs.existsSync(pdf.filename), 'Saves the pdf with a custom page size and footer') }) }) + +test('load with cookies js', function (t) { + t.plan(3) + + var server = require('http').createServer(function (req, res) { + res.write(req.headers.cookie) + res.end() + }) + + server.listen(0, function (err) { + t.error(err, 'http server for iframe started') + + var port = server.address().port + var filename = path.join(__dirname, 'cookies.pdf') + pdf.create(` + here is an iframe which receives the cookies + + + `, { + httpCookies: [{ + name: 'Valid-Cookie-Name', + value: 'Valid-Cookie-Value', + domain: 'localhost', + path: '/' + }] + }) + .toFile(filename, function (error, pdf) { + server.close() + t.error(error, 'There must be no render error') + t.assert(fs.existsSync(pdf.filename), 'Saves the pdf') + }) + }) +})