forked from FontoXML/docxml
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathe2e.test.tsx
More file actions
126 lines (117 loc) · 2.91 KB
/
Copy pathe2e.test.tsx
File metadata and controls
126 lines (117 loc) · 2.91 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/** @jsx jsx */
import { describe, it } from 'std/testing/bdd';
import Docx, {
// deno-lint-ignore verbatim-module-syntax
jsx,
Paragraph,
RelationshipType,
Section,
Text,
twip,
} from '../mod.ts';
import { QNS } from './utilities/src/namespaces.ts';
import {
expectDocumentToContain,
expectDocxToContain,
} from './utilities/src/tests.ts';
describe('End-to-end', () => {
describe('Text run formatting', () => {
const docx = Docx.fromJsx(
<Section>
<Paragraph>
<Text>Normal text</Text>
<Text color="red">Colored text</Text>
<Text isItalic>Italic text</Text>
<Text isBold>Bold text</Text>
<Text isUnderlined>Underlined default text</Text>
<Text isUnderlined="wave">Underlined wave text</Text>
<Text language="nl-NL">Buitenlandse tekst</Text>
</Paragraph>
</Section>
);
it('Unformatted', () =>
expectDocxToContain(
docx,
RelationshipType.officeDocument,
`
let $rpr := //${QNS.w}r[child::${QNS.w}t = "Normal text"]/${QNS.w}rPr
return not($rpr)
`
));
it('Color', () =>
expectDocxToContain(
docx,
RelationshipType.officeDocument,
`
let $rpr := //${QNS.w}r[child::${QNS.w}t = "Colored text"]/${QNS.w}rPr
return $rpr/${QNS.w}color/@${QNS.w}val = 'red'
`
));
it('Italic', () =>
expectDocxToContain(
docx,
RelationshipType.officeDocument,
`
let $rpr := //${QNS.w}r[child::${QNS.w}t = "Italic text"]/${QNS.w}rPr
return $rpr/(not(${QNS.w}b) and ${QNS.w}i)
`
));
it('Bold', () =>
expectDocxToContain(
docx,
RelationshipType.officeDocument,
`
let $rpr := //${QNS.w}r[child::${QNS.w}t = "Bold text"]/${QNS.w}rPr
return $rpr/(${QNS.w}b and not(${QNS.w}i))
`
));
it('Underlined', () => {
expectDocxToContain(
docx,
RelationshipType.officeDocument,
`
let $rpr := //${QNS.w}r[child::${QNS.w}t = "Underlined default text"]/${QNS.w}rPr
return $rpr/${QNS.w}u/@${QNS.w}val = 'single'
`
);
expectDocxToContain(
docx,
RelationshipType.officeDocument,
`
let $rpr := //${QNS.w}r[child::${QNS.w}t = "Underlined wave text"]/${QNS.w}rPr
return $rpr/${QNS.w}u/@${QNS.w}val = 'wave'
`
);
});
it('Language', () =>
expectDocxToContain(
docx,
RelationshipType.officeDocument,
`
let $rpr := //${QNS.w}r[child::${QNS.w}t = "Buitenlandse tekst"]/${QNS.w}rPr
return $rpr/${QNS.w}lang/@${QNS.w}val = "nl-NL"
`
));
});
describe('Paragraph style', () => {
const docx = Docx.fromNothing();
const name = docx.document.styles.add({
type: 'paragraph',
id: 'test',
paragraph: {
indentation: {
firstLine: twip(420),
},
},
});
it('Indentation', () =>
expectDocumentToContain(
docx,
RelationshipType.styles,
`
let $ppr := /*/${QNS.w}style[@${QNS.w}styleId = "${name}"]/${QNS.w}pPr
return boolean($ppr/${QNS.w}ind/@${QNS.w}firstLine = "420")
`
));
});
});