Skip to content

Commit b3ebba4

Browse files
committed
Add tests for grey fill color, multiline text, font color
1 parent 2ebfa20 commit b3ebba4

6 files changed

Lines changed: 45 additions & 0 deletions

File tree

2.37 KB
Binary file not shown.

specs/shapes/standard.spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,12 @@ describe('Drawing functions', () => {
100100

101101
comparePdf(doc.output(), 'lines.pdf', 'shapes')
102102
})
103+
104+
it('should use grey color mode', () => {
105+
const doc = jsPDF()
106+
doc.setFillColor(22)
107+
doc.rect(20, 20, 10, 10, 'F')
108+
109+
comparePdf(doc.output(), 'fill-color.pdf', 'shapes')
110+
})
103111
})

specs/text/reference/color.pdf

2.48 KB
Binary file not shown.
2.41 KB
Binary file not shown.

specs/text/reference/stroke.pdf

2.58 KB
Binary file not shown.

specs/text/standard.spec.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,41 @@ describe('Standard Text', () => {
6666
doc.text(20, 30, 'This is some normal sized text underneath.')
6767
comparePdf(doc.output(), 'different-sizes.pdf', 'text')
6868
})
69+
it('should support multiline text', () => {
70+
const doc = jsPDF()
71+
doc.text(20, 20, `This is a line
72+
break`)
73+
comparePdf(doc.output(), 'line-break.pdf', 'text')
74+
})
75+
76+
it('should support multiline text', () => {
77+
const doc = jsPDF()
78+
doc.text('Stroke on', 20, 20, { stroke: true })
79+
doc.text('Stroke on', 20, 40, { stroke: true })
80+
doc.text('Stroke off', 20, 60, { stroke: false })
81+
doc.text('Stroke on', 20, 80, { stroke: true })
82+
83+
comparePdf(doc.output(), 'stroke.pdf', 'text')
84+
})
85+
86+
it('should support multiline text', () => {
87+
const doc = jsPDF()
88+
doc.text('Stroke on', 20, 20, { stroke: true })
89+
doc.text('Stroke on', 20, 40, { stroke: true })
90+
doc.text('Stroke off', 20, 60, { stroke: false })
91+
doc.text('Stroke on', 20, 80, { stroke: true })
92+
93+
comparePdf(doc.output(), 'stroke.pdf', 'text')
94+
})
95+
96+
// @TODO: Implement passing color as a name
97+
it('should display two red lines of text', () => {
98+
const doc = jsPDF()
99+
doc.setTextColor('#FF0000')
100+
doc.text('Red on', 20, 20)
101+
doc.setTextColor(255, 0, 0)
102+
doc.text('Red on', 20, 40)
103+
104+
comparePdf(doc.output(), 'color.pdf', 'text')
105+
})
69106
})

0 commit comments

Comments
 (0)