Skip to content

Commit f778237

Browse files
committed
Fix tests
1 parent 5981aa2 commit f778237

File tree

1 file changed

+32
-19
lines changed

1 file changed

+32
-19
lines changed

test/annotations.test.js

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ const testXml = `
4343
`;
4444

4545
async function annotate(json) {
46-
const res = await util.axios.post('annotations/merge/annotate%2Fannotations.xml', json);
46+
const res = await util.axios.post('annotations/merge/annotate%2Fannotations.xml', json, {
47+
headers: {
48+
'Content-Type': 'application/json'
49+
}
50+
});
4751
expect(res.status).to.equal(200);
4852
expect(res).to.satisfyApiSpec;
4953
expect(res.data.changes).to.have.length(1);
@@ -69,7 +73,8 @@ describe('/api/annotations/merge', function() {
6973
});
7074

7175
it('deletes at start and wraps', async function() {
72-
const document = await annotate([
76+
const document = await annotate({
77+
annotations: [
7378
{
7479
"type": "delete",
7580
"node": "1.4.2.2.2",
@@ -101,13 +106,14 @@ describe('/api/annotations/merge', function() {
101106
"target": "#foo"
102107
}
103108
}
104-
]);
109+
]});
105110
const para = document.querySelector("body p:nth-child(1)");
106111
expect(para.outerHTML).xml.to.equal('<p xmlns="http://www.tei-c.org/ns/1.0">(<ref target="#foo"><hi>Gauger I</hi>, <hi>113</hi></ref>).</p>');
107112
});
108113

109114
it('deletes at end and wraps', async function() {
110-
const document = await annotate([
115+
const document = await annotate({
116+
annotations: [
111117
{
112118
"type": "delete",
113119
"node": "1.4.2.4.2",
@@ -139,13 +145,14 @@ describe('/api/annotations/merge', function() {
139145
"target": "#foo"
140146
}
141147
}
142-
]);
148+
]});
143149
const para = document.querySelector("body p:nth-child(2)");
144150
expect(para.outerHTML).xml.to.equal('<p xmlns="http://www.tei-c.org/ns/1.0">(<ref target="#foo"><hi>113</hi>, <hi>Gauger I</hi></ref>).</p>');
145151
});
146152

147153
it('annotate after nested note', async function() {
148-
const document = await annotate([
154+
const document = await annotate({
155+
annotations: [
149156
{
150157
"context": "1.4.2.8",
151158
"start": 20,
@@ -154,13 +161,14 @@ describe('/api/annotations/merge', function() {
154161
"type": "hi",
155162
"properties": {}
156163
}
157-
]);
164+
]});
158165
const para = document.querySelector("body p:nth-child(4)");
159166
expect(para.outerHTML).xml.to.equal('<p xmlns="http://www.tei-c.org/ns/1.0"><ref target="#">Starb am<note place="footnote">Fehlt.</note></ref>. Sammlung: <hi>Opuscula theologica</hi>.</p>');
160167
});
161168

162169
it('wrap to end of paragraph', async function() {
163-
const document = await annotate([
170+
const document = await annotate({
171+
annotations: [
164172
{
165173
"context": "1.4.2.16",
166174
"start": 210,
@@ -171,13 +179,14 @@ describe('/api/annotations/merge', function() {
171179
"target": "#foo"
172180
}
173181
}
174-
]);
182+
]});
175183
const para = document.querySelector("body p:nth-child(8)");
176184
expect(para.outerHTML).xml.to.equal('<p xmlns="http://www.tei-c.org/ns/1.0">Bei <persName type="author" ref="kbga-actors-8470">Budé</persName> (Anm. 21), S. 56f.59, finden sich zwei Briefe von Fontenelle an Turettini, in denen <persName ref="kbga-actors-8482">Fontenelle</persName> sich lobend über <persName ref="kbga-actors-1319">Werenfels</persName> äußert. Den erwähnten Dank formulierte <persName ref="kbga-actors-1319">Werenfels</persName> in Form eines Epigramms; vgl. <ref target="#foo"><persName type="author" ref="kbga-actors-1319">S. Werenfels</persName>, <hi rend="i">Fasciculus Epigrammatum</hi>, in: ders., <hi rend="i">Opuscula</hi> III (Anm. 20), S. 337–428, dort S. 384:</ref></p>');
177185
});
178186

179187
it('annotate after nested choice', async function() {
180-
const document = await annotate([
188+
const document = await annotate({
189+
annotations: [
181190
{
182191
"context": "1.4.2.10",
183192
"start": 9,
@@ -186,13 +195,14 @@ describe('/api/annotations/merge', function() {
186195
"type": "hi",
187196
"properties": {}
188197
}
189-
]);
198+
]});
190199
const para = document.querySelector("body p:nth-child(5)");
191200
expect(para.outerHTML).xml.to.equal('<p xmlns="http://www.tei-c.org/ns/1.0"><hi>Zum <choice><abbr>Bsp.</abbr><expan>Beispiel</expan></choice></hi> <hi>Opuscula theologica</hi>.</p>');
192201
});
193202

194203
it('insert choice/abbr/expan', async function() {
195-
const document = await annotate([
204+
const document = await annotate({
205+
annotations: [
196206
{
197207
"context": "1.4.2.12",
198208
"start": 6,
@@ -203,13 +213,14 @@ describe('/api/annotations/merge', function() {
203213
"expan": "sit amet"
204214
}
205215
}
206-
]);
216+
]});
207217
const para = document.querySelector("body p:nth-child(6)");
208218
expect(para.outerHTML).xml.to.equal('<p xmlns="http://www.tei-c.org/ns/1.0">Lorem <choice><abbr>ipsum dolor</abbr><expan>sit amet</expan></choice> sit amet.</p>');
209219
});
210220

211221
it('insert app/lem/rdg', async function() {
212-
const document = await annotate([
222+
const document = await annotate({
223+
annotations: [
213224
{
214225
"context": "1.4.2.12",
215226
"start": 6,
@@ -221,31 +232,33 @@ describe('/api/annotations/merge', function() {
221232
"rdg[1]": "sit amet"
222233
}
223234
}
224-
]);
235+
]});
225236
const para = document.querySelector("body p:nth-child(6)");
226237
expect(para.outerHTML).xml.to.equal('<p xmlns="http://www.tei-c.org/ns/1.0">Lorem <app><lem>ipsum dolor</lem><rdg wit="#me">sit amet</rdg></app> sit amet.</p>');
227238
});
228239

229240
it('delete choice/abbr/expan', async function() {
230-
const document = await annotate([
241+
const document = await annotate({
242+
annotations: [
231243
{
232244
"type": "delete",
233245
"node": "1.4.2.14.2",
234246
"context": "1.4.2.14"
235247
}
236-
]);
248+
]});
237249
const para = document.querySelector("body p:nth-child(7)");
238250
expect(para.outerHTML).xml.to.equal('<p xmlns="http://www.tei-c.org/ns/1.0">Lorem ipsum dolor sit amet.</p>');
239251
});
240252

241253
it('delete element containing note', async function() {
242-
const document = await annotate([
254+
const document = await annotate({
255+
annotations: [
243256
{
244257
"type": "delete",
245258
"node": "1.4.2.8.1",
246259
"context": "1.4.2.8"
247260
}
248-
]);
261+
]});
249262
const para = document.querySelector("body p:nth-child(4)");
250263
expect(para.outerHTML).xml.to.equal('<p xmlns="http://www.tei-c.org/ns/1.0">Starb am<note place="footnote">Fehlt.</note>. Sammlung: Opuscula theologica.</p>');
251264
});

0 commit comments

Comments
 (0)