From f778237e9ee23697512b99d350866dab97f52332 Mon Sep 17 00:00:00 2001 From: Wolfgang Meier Date: Thu, 10 Oct 2024 12:46:21 +0200 Subject: [PATCH] Fix tests --- test/annotations.test.js | 51 +++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/test/annotations.test.js b/test/annotations.test.js index e1aedf984..69d032921 100644 --- a/test/annotations.test.js +++ b/test/annotations.test.js @@ -43,7 +43,11 @@ const testXml = ` `; async function annotate(json) { - const res = await util.axios.post('annotations/merge/annotate%2Fannotations.xml', json); + const res = await util.axios.post('annotations/merge/annotate%2Fannotations.xml', json, { + headers: { + 'Content-Type': 'application/json' + } + }); expect(res.status).to.equal(200); expect(res).to.satisfyApiSpec; expect(res.data.changes).to.have.length(1); @@ -69,7 +73,8 @@ describe('/api/annotations/merge', function() { }); it('deletes at start and wraps', async function() { - const document = await annotate([ + const document = await annotate({ + annotations: [ { "type": "delete", "node": "1.4.2.2.2", @@ -101,13 +106,14 @@ describe('/api/annotations/merge', function() { "target": "#foo" } } - ]); + ]}); const para = document.querySelector("body p:nth-child(1)"); expect(para.outerHTML).xml.to.equal('

(Gauger I, 113).

'); }); it('deletes at end and wraps', async function() { - const document = await annotate([ + const document = await annotate({ + annotations: [ { "type": "delete", "node": "1.4.2.4.2", @@ -139,13 +145,14 @@ describe('/api/annotations/merge', function() { "target": "#foo" } } - ]); + ]}); const para = document.querySelector("body p:nth-child(2)"); expect(para.outerHTML).xml.to.equal('

(113, Gauger I).

'); }); it('annotate after nested note', async function() { - const document = await annotate([ + const document = await annotate({ + annotations: [ { "context": "1.4.2.8", "start": 20, @@ -154,13 +161,14 @@ describe('/api/annotations/merge', function() { "type": "hi", "properties": {} } - ]); + ]}); const para = document.querySelector("body p:nth-child(4)"); expect(para.outerHTML).xml.to.equal('

Starb amFehlt.. Sammlung: Opuscula theologica.

'); }); it('wrap to end of paragraph', async function() { - const document = await annotate([ + const document = await annotate({ + annotations: [ { "context": "1.4.2.16", "start": 210, @@ -171,13 +179,14 @@ describe('/api/annotations/merge', function() { "target": "#foo" } } - ]); + ]}); const para = document.querySelector("body p:nth-child(8)"); expect(para.outerHTML).xml.to.equal('

Bei Budé (Anm. 21), S. 56f.59, finden sich zwei Briefe von Fontenelle an Turettini, in denen Fontenelle sich lobend über Werenfels äußert. Den erwähnten Dank formulierte Werenfels in Form eines Epigramms; vgl. S. Werenfels, Fasciculus Epigrammatum, in: ders., Opuscula III (Anm. 20), S. 337–428, dort S. 384:

'); }); it('annotate after nested choice', async function() { - const document = await annotate([ + const document = await annotate({ + annotations: [ { "context": "1.4.2.10", "start": 9, @@ -186,13 +195,14 @@ describe('/api/annotations/merge', function() { "type": "hi", "properties": {} } - ]); + ]}); const para = document.querySelector("body p:nth-child(5)"); expect(para.outerHTML).xml.to.equal('

Zum Bsp.Beispiel Opuscula theologica.

'); }); it('insert choice/abbr/expan', async function() { - const document = await annotate([ + const document = await annotate({ + annotations: [ { "context": "1.4.2.12", "start": 6, @@ -203,13 +213,14 @@ describe('/api/annotations/merge', function() { "expan": "sit amet" } } - ]); + ]}); const para = document.querySelector("body p:nth-child(6)"); expect(para.outerHTML).xml.to.equal('

Lorem ipsum dolorsit amet sit amet.

'); }); it('insert app/lem/rdg', async function() { - const document = await annotate([ + const document = await annotate({ + annotations: [ { "context": "1.4.2.12", "start": 6, @@ -221,31 +232,33 @@ describe('/api/annotations/merge', function() { "rdg[1]": "sit amet" } } - ]); + ]}); const para = document.querySelector("body p:nth-child(6)"); expect(para.outerHTML).xml.to.equal('

Lorem ipsum dolorsit amet sit amet.

'); }); it('delete choice/abbr/expan', async function() { - const document = await annotate([ + const document = await annotate({ + annotations: [ { "type": "delete", "node": "1.4.2.14.2", "context": "1.4.2.14" } - ]); + ]}); const para = document.querySelector("body p:nth-child(7)"); expect(para.outerHTML).xml.to.equal('

Lorem ipsum dolor sit amet.

'); }); it('delete element containing note', async function() { - const document = await annotate([ + const document = await annotate({ + annotations: [ { "type": "delete", "node": "1.4.2.8.1", "context": "1.4.2.8" } - ]); + ]}); const para = document.querySelector("body p:nth-child(4)"); expect(para.outerHTML).xml.to.equal('

Starb amFehlt.. Sammlung: Opuscula theologica.

'); });