Skip to content

Commit f1f78a5

Browse files
committed
Add test for http cookie support
1 parent 84ac0a2 commit f1f78a5

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/index.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,36 @@ test('load external js', function (t) {
222222
t.assert(fs.existsSync(pdf.filename), 'Saves the pdf with a custom page size and footer')
223223
})
224224
})
225+
226+
test('load with cookies js', function (t) {
227+
t.plan(3)
228+
229+
var server = require('http').createServer(function (req, res) {
230+
res.write(req.headers.cookie)
231+
res.end()
232+
})
233+
234+
server.listen(0, function (err) {
235+
t.error(err, 'http server for iframe started')
236+
237+
var port = server.address().port
238+
var filename = path.join(__dirname, 'cookies.pdf')
239+
pdf.create(`
240+
<body>here is an iframe which receives the cookies
241+
<iframe src="http://localhost:${port}" width="400" height="100"></iframe>
242+
</body>
243+
`, {
244+
httpCookies: [{
245+
name: 'Valid-Cookie-Name',
246+
value: 'Valid-Cookie-Value',
247+
domain: 'localhost',
248+
path: '/'
249+
}]
250+
})
251+
.toFile(filename, function (error, pdf) {
252+
server.close()
253+
t.error(error, 'There must be no render error')
254+
t.assert(fs.existsSync(pdf.filename), 'Saves the pdf')
255+
})
256+
})
257+
})

0 commit comments

Comments
 (0)