From 77b61ffc85a0eaff30c5b1cb6c73f49ea8c16af3 Mon Sep 17 00:00:00 2001 From: "Daniel W. Hieber" Date: Sat, 16 Mar 2024 13:56:00 -0500 Subject: [PATCH] FIX: Adjust code to handle new HTML structure for literal translations --- src/utterance/literal.js | 2 +- test/index.test.js | 13 +++++++------ test/utterance.test.js | 10 ++++++---- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/utterance/literal.js b/src/utterance/literal.js index 10495c9..3e722b5 100644 --- a/src/utterance/literal.js +++ b/src/utterance/literal.js @@ -13,7 +13,7 @@ export default function createLiteral(data, { analysisLang }) { for (const lang in data) { const lit = data[lang] - html += `

lit. ${ addEmphasis(lit) }

` } return html diff --git a/test/index.test.js b/test/index.test.js index 9e51937..d4f0f8f 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -6,7 +6,7 @@ import parse from './utilities/convertAndParse.js' import parseClassString from './utilities/parseClassString.js' import { Swahili } from '../samples/data/data.js' -describe(`scription2html`, function() { +describe(`dlx2html`, function() { it(`wraps utterances in
by default`, async function() { @@ -66,13 +66,14 @@ describe(`scription2html`, function() { ` const analysisLang = `sp` - const { dom } = await parse(scription, { analysisLang }) + const { dom, html } = await parse(scription, { analysisLang }) - const lit = findElementByClass(dom, `lit`) - const tln = findElementByClass(dom, `tln`) - const meta = findElementByClass(dom, `ex-header`) + const lit = findElementByClass(dom, `lit`) + const tln = findElementByClass(dom, `tln`) + const meta = findElementByClass(dom, `ex-header`) + const literalTranslation = findElementByClass(lit, `tln`) - expect(getAttribute(lit, `lang`)).to.equal(analysisLang) + expect(getAttribute(literalTranslation, `lang`)).to.equal(analysisLang) expect(getAttribute(tln, `lang`)).to.equal(analysisLang) expect(getAttribute(meta, `lang`)).to.equal(analysisLang) diff --git a/test/utterance.test.js b/test/utterance.test.js index 79ea1ee..67a75ff 100644 --- a/test/utterance.test.js +++ b/test/utterance.test.js @@ -79,11 +79,13 @@ describe(`utterance`, function() { expect(literal).to.have.length(2) const [eng, spa] = literal + const engLiteral = findElementByClass(eng, `tln`) + const spaLiteral = findElementByClass(spa, `tln`) - expect(getAttribute(eng, `lang`)).to.equal(`en`) - expect(getAttribute(spa, `lang`)).to.equal(`sp`) - expect(getTextContent(eng)).to.equal(`they ate each other's mouths`) - expect(getTextContent(spa)).to.equal(`se comen sus bocas`) + expect(getAttribute(engLiteral, `lang`)).to.equal(`en`) + expect(getAttribute(spaLiteral, `lang`)).to.equal(`sp`) + expect(getTextContent(engLiteral)).to.equal(`they ate each other's mouths`) + expect(getTextContent(spaLiteral)).to.equal(`se comen sus bocas`) })