From 8853c4a83b27de9efe0457abd81a028f9b1658d4 Mon Sep 17 00:00:00 2001 From: "Daniel W. Hieber" Date: Tue, 9 Apr 2024 11:53:05 -0500 Subject: [PATCH] DEV: Order tests alphabetically --- test/utterance.test.js | 100 +++++++------- test/words.test.js | 286 ++++++++++++++++++++--------------------- 2 files changed, 193 insertions(+), 193 deletions(-) diff --git a/test/utterance.test.js b/test/utterance.test.js index dcb9d32..7d1b225 100644 --- a/test/utterance.test.js +++ b/test/utterance.test.js @@ -131,6 +131,56 @@ describe(`utterance`, function() { }) + describe(`phonemic transcription`, function() { + + it(`produces one line per orthography`, async function() { + + const scription = ` + \\txn-mod waxdungu qasi + \\txn-swad wašdungu ʔasi + \\txn-apa waštʼunkʼu ʔasi + \\m waxt-qungu qasi + \\gl day-one man + \\tln one day a man + ` + + const { dom } = await parse(scription) + const [ex] = dom.childNodes + const transcripts = findElementsByClass(ex, `txn`) + + expect(transcripts).to.have.length(3) + + const [mod, swad, apa] = transcripts + + expect(getAttribute(mod, `data-ortho`)).to.equal(`mod`) + expect(getAttribute(swad, `data-ortho`)).to.equal(`swad`) + expect(getAttribute(apa, `data-ortho`)).to.equal(`apa`) + + expect(getTextContent(mod)).to.equal(`waxdungu qasi`) + expect(getTextContent(swad)).to.equal(`wašdungu ʔasi`) + expect(getTextContent(apa)).to.equal(`waštʼunkʼu ʔasi`) + + }) + + it(`renders emphasis`, async function() { + + const scription = ` + \\txn wax*d*ungu qasi + \\m waxt-qungu qasi + \\gl day-one man + \\tln one day a man + ` + + const { dom } = await parse(scription) + const txn = findElementByClass(dom, `txn`) + const b = findElement(txn, el => getTagName(el) === `b`) + + expect(getTextContent(b)).to.equal(`d`) + + }) + + }) + describe(`phonetic transcription`, function() { it(`renders`, async function() { @@ -200,56 +250,6 @@ describe(`utterance`, function() { }) - describe(`phonemic transcription`, function() { - - it(`produces one line per orthography`, async function() { - - const scription = ` - \\txn-mod waxdungu qasi - \\txn-swad wašdungu ʔasi - \\txn-apa waštʼunkʼu ʔasi - \\m waxt-qungu qasi - \\gl day-one man - \\tln one day a man - ` - - const { dom } = await parse(scription) - const [ex] = dom.childNodes - const transcripts = findElementsByClass(ex, `txn`) - - expect(transcripts).to.have.length(3) - - const [mod, swad, apa] = transcripts - - expect(getAttribute(mod, `data-ortho`)).to.equal(`mod`) - expect(getAttribute(swad, `data-ortho`)).to.equal(`swad`) - expect(getAttribute(apa, `data-ortho`)).to.equal(`apa`) - - expect(getTextContent(mod)).to.equal(`waxdungu qasi`) - expect(getTextContent(swad)).to.equal(`wašdungu ʔasi`) - expect(getTextContent(apa)).to.equal(`waštʼunkʼu ʔasi`) - - }) - - it(`renders emphasis`, async function() { - - const scription = ` - \\txn wax*d*ungu qasi - \\m waxt-qungu qasi - \\gl day-one man - \\tln one day a man - ` - - const { dom } = await parse(scription) - const txn = findElementByClass(dom, `txn`) - const b = findElement(txn, el => getTagName(el) === `b`) - - expect(getTextContent(b)).to.equal(`d`) - - }) - - }) - describe(`source`, function() { it(`is not present when there is no data`, async function() { diff --git a/test/words.test.js b/test/words.test.js index 86a54fa..ebc825a 100644 --- a/test/words.test.js +++ b/test/words.test.js @@ -44,58 +44,151 @@ describe(`words`, function() { }) - describe(`word transcription`, function() { + describe(`glosses`, function() { - it(`has the correct number of lines`, async function() { + it(`renders (with non-breaking hyphens)`, async function() { const scription = ` ninakupenda ni-na-ku-pend-a 1SG.SUBJ-PRES-2SG.OBJ-love-IND - I love you` + I love you + ` const { dom } = await parse(scription) - const word = findElementByClass(dom, `word`) + const morphemes = findElementByClass(dom, `glosses`) - expect(word.childNodes).to.have.length(2) + expect(getTextContent(morphemes)).to.equal(`1SG.SUBJ‑PRES‑2SG.OBJ‑love‑IND`) // non-breaking hyphens }) - it(`renders in multiple orthographies`, async function() { + it(`supports multiple analysis languages`, async function() { const scription = ` - \\w-mod waxdungu qasi - \\w-swad wašdungu ʔasi - \\m waxt-qungu qasi - \\gl day-one man - \\tln one day a man + \\txn ninakupenda + \\m ni-na-ku-pend-a + \\gl-en 1SG.SUBJ-PRES-2SG.OBJ-love-IND + \\gl-sp 1SG.SJ-PRES-2SG.OJ-amar-IND + \\tln I love you ` - const { dom } = await parse(scription) - const wordsContainer = findElementByClass(dom, `words`) - const [firstWord, secondWord] = wordsContainer.childNodes.filter(node => node.tagName === `li`) - - const firstText = getTextContent(firstWord) - expect(firstText).to.include(`waxdungu`) - expect(firstText).to.include(`wašdungu`) + const { dom } = await parse(scription) + const [firstGloss, secondGloss] = findElementsByClass(dom, `glosses`) - const secondText = getTextContent(secondWord) - expect(secondText).to.include(`qasi`) - expect(secondText).to.include(`ʔasi`) + expect(getTextContent(firstGloss)).to.include(`SUBJ`) + expect(getTextContent(secondGloss)).to.include(`SJ`) }) it(`supports emphasis`, async function() { const scription = ` - \\w *waxdungu* qasi - \\wlt *one.day* man + ninakupenda + ni-na-ku-pend-a + 1SG.SUBJ-PRES-*2SG.OBJ*-love-IND + I love you ` const { dom } = await parse(scription) - const b = findElement(dom, el => getTagName(el) === `b`) + const b = findElement(dom, el => getTagName(el) === `b`) - expect(getTextContent(b)).to.equal(`waxdungu`) + expect(getTextContent(b)).to.equal(`2SG.OBJ`) + + }) + + it(`option: glosses = false (default)`, async function() { + + const scription = ` + ninakupenda + ni-na-ku-pend-a + 1SG.SUBJ-PRES-2SG.OBJ-love-IND + I love you + ` + + const { dom } = await parse(scription) + const abbr = findElement(dom, el => getTagName(el) === `abbr`) + + expect(abbr).not.to.exist + + }) + + it(`option: glosses = true`, async function() { + + const scription = ` + ninakupenda + ni-na-ku-pend-a + 1SG.SUBJ-PRES-2SG.OBJ-love-IND + I love you + ` + + const { dom, html } = await parse(scription, { glosses: true }) + const glosses = findElements(dom, el => getTagName(el) === `abbr`) + const [person, num] = glosses + + expect(glosses).to.have.length(8) + expect(getTextContent(person)).to.equal(`1`) + expect(getTextContent(num)).to.equal(`sg`) + + }) + + it(`option: glosses (lowercase glosses)`, async function() { + + const scription = ` + ninakupenda + ni-na-ku-pend-a + 1sg.SUBJ-PRES-2sg.OBJ-love-IND + I love you + ` + + const { dom } = await parse(scription, { glosses: true }) + const glosses = findElements(dom, el => getTagName(el) === `abbr`) + const [person, num] = glosses + + expect(glosses).to.have.length(8) + expect(getTextContent(person)).to.equal(`1`) + expect(getTextContent(num)).to.equal(`sg`) + + }) + + it(`option: glosses (lowercase smallcaps)`, async function() { + + const scription = ` + ninakupenda + ni-na-ku-pend-a + 1SG.SUBJ-PRES-2SG.OBJ-love-IND + I love you + ` + + const { dom, html } = await parse(scription, { glosses: true }) + const glosses = findElements(dom, el => getTagName(el) === `abbr`) + const [person, num] = glosses + + expect(getTextContent(person)).to.equal(`1`) + expect(getTextContent(num)).to.equal(`sg`) + + }) + + it(`option: abbreviations`, async function() { + + const scription = ` + ninakupenda + ni-na-ku-pend-a + 1SG.SUBJ-PRES-2SG.OBJ-love-IND + I love you + ` + + const abbreviations = { + 1: `first person`, + SG: `singular`, + } + + const { dom } = await parse(scription, { abbreviations, glosses: true }) + const glosses = findElements(dom, el => getTagName(el) === `abbr`) + const [person, num] = glosses + + expect(glosses).to.have.length(8) + expect(getAttribute(person, `title`)).to.equal(`first person`) + expect(getAttribute(num, `title`)).to.equal(`singular`) }) @@ -220,151 +313,58 @@ describe(`words`, function() { }) - describe(`glosses`, function() { + describe(`word transcription`, function() { - it(`renders (with non-breaking hyphens)`, async function() { + it(`has the correct number of lines`, async function() { const scription = ` ninakupenda ni-na-ku-pend-a 1SG.SUBJ-PRES-2SG.OBJ-love-IND - I love you - ` - - const { dom } = await parse(scription) - const morphemes = findElementByClass(dom, `glosses`) - - expect(getTextContent(morphemes)).to.equal(`1SG.SUBJ‑PRES‑2SG.OBJ‑love‑IND`) // non-breaking hyphens - - }) - - it(`supports multiple analysis languages`, async function() { - - const scription = ` - \\txn ninakupenda - \\m ni-na-ku-pend-a - \\gl-en 1SG.SUBJ-PRES-2SG.OBJ-love-IND - \\gl-sp 1SG.SJ-PRES-2SG.OJ-amar-IND - \\tln I love you - ` - - const { dom } = await parse(scription) - const [firstGloss, secondGloss] = findElementsByClass(dom, `glosses`) - - expect(getTextContent(firstGloss)).to.include(`SUBJ`) - expect(getTextContent(secondGloss)).to.include(`SJ`) - - }) - - it(`supports emphasis`, async function() { - - const scription = ` - ninakupenda - ni-na-ku-pend-a - 1SG.SUBJ-PRES-*2SG.OBJ*-love-IND - I love you - ` + I love you` const { dom } = await parse(scription) - const b = findElement(dom, el => getTagName(el) === `b`) + const word = findElementByClass(dom, `word`) - expect(getTextContent(b)).to.equal(`2SG.OBJ`) + expect(word.childNodes).to.have.length(2) }) - it(`option: glosses = false (default)`, async function() { + it(`renders in multiple orthographies`, async function() { const scription = ` - ninakupenda - ni-na-ku-pend-a - 1SG.SUBJ-PRES-2SG.OBJ-love-IND - I love you + \\w-mod waxdungu qasi + \\w-swad wašdungu ʔasi + \\m waxt-qungu qasi + \\gl day-one man + \\tln one day a man ` const { dom } = await parse(scription) - const abbr = findElement(dom, el => getTagName(el) === `abbr`) - - expect(abbr).not.to.exist - - }) - - it(`option: glosses = true`, async function() { - - const scription = ` - ninakupenda - ni-na-ku-pend-a - 1SG.SUBJ-PRES-2SG.OBJ-love-IND - I love you - ` - - const { dom, html } = await parse(scription, { glosses: true }) - const glosses = findElements(dom, el => getTagName(el) === `abbr`) - const [person, num] = glosses - - expect(glosses).to.have.length(8) - expect(getTextContent(person)).to.equal(`1`) - expect(getTextContent(num)).to.equal(`sg`) - - }) - - it(`option: glosses (lowercase glosses)`, async function() { - - const scription = ` - ninakupenda - ni-na-ku-pend-a - 1sg.SUBJ-PRES-2sg.OBJ-love-IND - I love you - ` - - const { dom } = await parse(scription, { glosses: true }) - const glosses = findElements(dom, el => getTagName(el) === `abbr`) - const [person, num] = glosses - - expect(glosses).to.have.length(8) - expect(getTextContent(person)).to.equal(`1`) - expect(getTextContent(num)).to.equal(`sg`) - - }) - - it(`option: glosses (lowercase smallcaps)`, async function() { - - const scription = ` - ninakupenda - ni-na-ku-pend-a - 1SG.SUBJ-PRES-2SG.OBJ-love-IND - I love you - ` + const wordsContainer = findElementByClass(dom, `words`) + const [firstWord, secondWord] = wordsContainer.childNodes.filter(node => node.tagName === `li`) - const { dom, html } = await parse(scription, { glosses: true }) - const glosses = findElements(dom, el => getTagName(el) === `abbr`) - const [person, num] = glosses + const firstText = getTextContent(firstWord) + expect(firstText).to.include(`waxdungu`) + expect(firstText).to.include(`wašdungu`) - expect(getTextContent(person)).to.equal(`1`) - expect(getTextContent(num)).to.equal(`sg`) + const secondText = getTextContent(secondWord) + expect(secondText).to.include(`qasi`) + expect(secondText).to.include(`ʔasi`) }) - it(`option: abbreviations`, async function() { + it(`supports emphasis`, async function() { const scription = ` - ninakupenda - ni-na-ku-pend-a - 1SG.SUBJ-PRES-2SG.OBJ-love-IND - I love you + \\w *waxdungu* qasi + \\wlt *one.day* man ` - const abbreviations = { - 1: `first person`, - SG: `singular`, - } - - const { dom } = await parse(scription, { abbreviations, glosses: true }) - const glosses = findElements(dom, el => getTagName(el) === `abbr`) - const [person, num] = glosses + const { dom } = await parse(scription) + const b = findElement(dom, el => getTagName(el) === `b`) - expect(glosses).to.have.length(8) - expect(getAttribute(person, `title`)).to.equal(`first person`) - expect(getAttribute(num, `title`)).to.equal(`singular`) + expect(getTextContent(b)).to.equal(`waxdungu`) })