Skip to content

Commit 26cb87a

Browse files
committed
Add tests for zoom displaymodes
1 parent 69064f9 commit 26cb87a

6 files changed

Lines changed: 58 additions & 0 deletions

File tree

specs/init/display-mode.spec.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
'use strict'
2+
/* global describe, it, jsPDF, comparePdf, jasmine, expect */
3+
/**
4+
* Standard spec tests
5+
*
6+
* These tests return the datauristring so that reference files can be generated.
7+
* We compare the exact output.
8+
*/
9+
10+
describe('jsPDF init display modes', () => {
11+
it('should set zoom mode to fullheight', () => {
12+
const doc = jsPDF()
13+
doc.setDisplayMode('fullheight')
14+
doc.text(10, 10, 'This is a test')
15+
doc.output()
16+
comparePdf(doc.output(), 'zoom-full-height.pdf', 'init')
17+
})
18+
19+
it('should set zoom mode to fullpage', () => {
20+
const doc = jsPDF('landscape')
21+
doc.setDisplayMode('fullpage')
22+
doc.text(10, 10, 'This is a test')
23+
doc.output()
24+
comparePdf(doc.output(), 'zoom-full-page.pdf', 'init')
25+
})
26+
27+
it('should set zoom mode to original', () => {
28+
const doc = jsPDF('landscape')
29+
doc.setDisplayMode('original')
30+
doc.text(10, 10, 'This is a test')
31+
doc.output()
32+
comparePdf(doc.output(), 'zoom-original.pdf', 'init')
33+
})
34+
35+
it('should set zoom mode to 2x', () => {
36+
const doc = jsPDF('landscape')
37+
doc.setDisplayMode(2)
38+
doc.text(20, 20, 'This is a test')
39+
doc.output()
40+
comparePdf(doc.output(), 'zoom-2x.pdf', 'init')
41+
})
42+
43+
it('should set zoom mode to 3x', () => {
44+
const doc = jsPDF('landscape')
45+
doc.setDisplayMode(3)
46+
doc.text(20, 20, 'This is a test')
47+
doc.output()
48+
comparePdf(doc.output(), 'zoom-3x.pdf', 'init')
49+
})
50+
51+
it('should set zoom mode to 3x', () => {
52+
const doc = jsPDF('landscape')
53+
doc.setDisplayMode('300%')
54+
doc.text(20, 20, 'This is a test')
55+
doc.output()
56+
comparePdf(doc.output(), 'zoom-3x.pdf', 'init')
57+
})
58+
})

specs/init/reference/zoom-2x.pdf

2.41 KB
Binary file not shown.

specs/init/reference/zoom-3x.pdf

2.41 KB
Binary file not shown.
2.4 KB
Binary file not shown.
2.39 KB
Binary file not shown.
2.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)