-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
text.spec.js
67 lines (61 loc) · 1.96 KB
/
text.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { runDocTest } from './helpers';
describe('text', function() {
test('simple text', function() {
return runDocTest(function(doc) {
doc.font('tests/fonts/Roboto-Regular.ttf');
doc.text('Really simple text', 100, 100);
});
});
test('alignment', function() {
return runDocTest(function(doc) {
doc.font('tests/fonts/Roboto-Regular.ttf');
doc.text('Left aligned text', { align: 'left' });
doc.text('Right aligned text', { align: 'right' });
doc.text(
'Justified aligned text - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam in suscipit purus.',
{ align: 'justify' }
);
});
});
test('soft hyphen', function() {
return runDocTest(function(doc) {
doc.font('tests/fonts/Roboto-Regular.ttf');
doc.text(
'Text with soft hyphen - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lo ip\u00ADsum',
{ align: 'justify' }
);
doc.text(
'Text with soft hyphen on the edge - ttttestttestttestttestttestttestttestttestttestttestttes\u00ADtt\u00ADt',
{ align: 'justify' }
);
});
});
test('decoration', function() {
return runDocTest(function(doc) {
doc.font('tests/fonts/Roboto-Regular.ttf');
doc.fillColor('blue').text('Here is a link!', 100, 100, {
link: 'http://google.com/',
underline: true
});
doc.text('Strike', 100, 130, {
strike: true
});
doc.text('Strike', 100, 160, {
underline: true,
strike: true
});
});
});
test('list', function() {
return runDocTest(function(doc) {
doc.font('tests/fonts/Roboto-Regular.ttf');
doc.fillColor('#000').list(['One', 'Two', 'Three'], 100, 150);
});
});
test('list with line breaks in items', function() {
return runDocTest(function(doc) {
doc.font('tests/fonts/Roboto-Regular.ttf');
doc.list(['Foo\nBar', 'Foo\rBar', 'Foo\r\nBar'], [100, 150]);
})
})
});