Skip to content

Commit 89a41e3

Browse files
committed
Extract business card test into separate file
1 parent 63ba98f commit 89a41e3

File tree

4 files changed

+29
-28
lines changed

4 files changed

+29
-28
lines changed
0 Bytes
Binary file not shown.

examples/businesscard/test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
var test = require('tape')
2+
var pdf = require('../../')
3+
var path = require('path')
4+
var fs = require('fs')
5+
6+
test('allows custom html and css', function (t) {
7+
t.plan(3)
8+
9+
var template = path.join(__dirname, 'businesscard.html')
10+
var filename = template.replace('.html', '.pdf')
11+
var templateHtml = fs.readFileSync(template, 'utf8')
12+
13+
var image = path.join('file://', __dirname, 'image.png')
14+
templateHtml = templateHtml.replace('{{image}}', image)
15+
16+
var options = {
17+
width: '50mm',
18+
height: '90mm'
19+
}
20+
21+
pdf
22+
.create(templateHtml, options)
23+
.toFile(filename, function (err, pdf) {
24+
t.error(err)
25+
t.assert(pdf.filename, 'Returns the filename')
26+
t.assert(fs.existsSync(pdf.filename), 'Saves the file to the desired destination')
27+
})
28+
})

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"html-pdf": "bin/index.js"
1414
},
1515
"scripts": {
16-
"test": "standard && node test/index.js"
16+
"test": "standard && tape test/index.js examples/*/test.js"
1717
},
1818
"author": "Marc Bachmann",
1919
"license": "MIT",

test/index.js

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -115,33 +115,6 @@ test('pdf.create(html[, options]).toStream(callback)', function (t) {
115115
})
116116
})
117117

118-
//
119-
// Options
120-
//
121-
test('allows custom html and css', function (t) {
122-
t.plan(3)
123-
124-
var template = path.join(__dirname, '../examples/businesscard/businesscard.html')
125-
var filename = template.replace('.html', '.pdf')
126-
var templateHtml = fs.readFileSync(template, 'utf8')
127-
128-
var image = path.join('file://', __dirname, '../examples/businesscard/image.png')
129-
templateHtml = templateHtml.replace('{{image}}', image)
130-
131-
var options = {
132-
width: '50mm',
133-
height: '90mm'
134-
}
135-
136-
pdf
137-
.create(templateHtml, options)
138-
.toFile(filename, function (err, pdf) {
139-
t.error(err)
140-
t.assert(pdf.filename, 'Returns the filename')
141-
t.assert(fs.existsSync(pdf.filename), 'Saves the file to the desired destination')
142-
})
143-
})
144-
145118
test('allows invalid phantomPath', function (t) {
146119
t.plan(3)
147120

0 commit comments

Comments
 (0)