Skip to content

Commit

Permalink
Add test for http cookie support
Browse files Browse the repository at this point in the history
  • Loading branch information
marcbachmann committed Sep 27, 2017
1 parent 84ac0a2 commit f1f78a5
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/index.js
Expand Up @@ -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(`
<body>here is an iframe which receives the cookies
<iframe src="http://localhost:${port}" width="400" height="100"></iframe>
</body>
`, {
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')
})
})
})

0 comments on commit f1f78a5

Please sign in to comment.