|
| 1 | +/** |
| 2 | + * Tests for the MD conversion script. Each test corresponds to an entry in the test database. The value of the "test" field in the entry must be the same as the title of the test. |
| 3 | + */ |
| 4 | + |
| 5 | +import convert from './AECD.js'; |
| 6 | +import { expect } from 'chai'; |
| 7 | +import { fileURLToPath } from 'url'; |
| 8 | +import fs from 'fs-extra'; |
| 9 | +import getTestEntry from '../../test/getTestEntry.js'; |
| 10 | + |
| 11 | +import { |
| 12 | + dirname as getDirname, |
| 13 | + join as joinPaths, |
| 14 | +} from 'path'; |
| 15 | + |
| 16 | +const { |
| 17 | + readFile, |
| 18 | + remove, |
| 19 | +} = fs; |
| 20 | + |
| 21 | +describe(`AECD conversion script`, function() { |
| 22 | + |
| 23 | + const __dirname = getDirname(fileURLToPath(import.meta.url)); |
| 24 | + const inputPath = joinPaths(__dirname, `./AECD.test.tsv`); |
| 25 | + const outputPath = joinPaths(__dirname, `./AECD.test.ndjson`); |
| 26 | + |
| 27 | + before(async function convertTestData() { |
| 28 | + |
| 29 | + const { entries, errors } = await convert(inputPath, outputPath); |
| 30 | + |
| 31 | + this.data = entries; |
| 32 | + this.errors = errors; |
| 33 | + |
| 34 | + }); |
| 35 | + |
| 36 | + after(async function removeTestData() { |
| 37 | + await remove(outputPath); |
| 38 | + }); |
| 39 | + |
| 40 | + // context(`cross-references`, function() { |
| 41 | + // it(`stores cross-references in lexicalRelations`, function() { |
| 42 | + |
| 43 | + // const { lexicalRelations } = getTestEntry(this.data, this.test.title); |
| 44 | + // expect(lexicalRelations.every(relation => relation.relation === `see`)); |
| 45 | + // const [a, b, c] = lexicalRelations; |
| 46 | + // expect(a.head.md).to.equal(`awina`); |
| 47 | + // expect(b.head.md).to.equal(`anihi`); |
| 48 | + // expect(c.head.md).to.equal(`wiya`); |
| 49 | + // }); |
| 50 | + // }); |
| 51 | + |
| 52 | + // context(`CW mapping`, function() { |
| 53 | + // it(`stores the CW mapping`, function() { |
| 54 | + // const { mapping } = getTestEntry(this.data, this.test.title); |
| 55 | + // expect(mapping.analysis).to.equal(`âhkohêw+V+TA+Ind+Prs+3Sg+4Sg/PlO`); |
| 56 | + // expect(mapping.definition).to.equal(`s/he gives s.o. a sharp pain, s/he gives s.o. a great deal of pain; s/he hurts s.o.`); |
| 57 | + // expect(mapping.lemma).to.equal(`âhkohêw`); |
| 58 | + // expect(mapping.type).to.equal(`broad`); |
| 59 | + // }); |
| 60 | + // }); |
| 61 | + |
| 62 | + // context(`definitions`, function() { |
| 63 | + // it(`separates senses`, function() { |
| 64 | + // const { senses } = getTestEntry(this.data, this.test.title); |
| 65 | + // const [senseA, senseB] = senses; |
| 66 | + // expect(senseA.definition).to.equal(`A Sioux Indian.`); |
| 67 | + // expect(senseB.definition).to.equal(`A male pow-wow dancer.`); |
| 68 | + // }); |
| 69 | + // }); |
| 70 | + |
| 71 | + context(`Syllabics+Standardized`, function() { |
| 72 | + it(`copies syllabics and standardized verbatim`, function() { |
| 73 | + const { head } = getTestEntry(this.data, this.test.title); |
| 74 | + expect(head.ae).to.equal(`acâhkos`); |
| 75 | + expect(head.syll).to.equal(`ᐊᒐᐦᑯᐢ`); |
| 76 | + }); |
| 77 | + }); |
| 78 | + |
| 79 | + // context(`English_Search`, function() { |
| 80 | + // it(`copies the English_Search field verbatim`, function() { |
| 81 | + // const { English_Search } = getTestEntry(this.data, this.test.title); |
| 82 | + // expect(English_Search).to.equal(`be counted.`); |
| 83 | + // }); |
| 84 | + // }); |
| 85 | + |
| 86 | + // context(`examples`, function() { |
| 87 | + // it(`stores examples`, function() { |
| 88 | + // const { examples: [a, b] } = getTestEntry(this.data, this.test.title); |
| 89 | + // expect(a.transcription.md).to.equal(`apho etikwe`); |
| 90 | + // expect(a.translation).to.equal(`maybe`); |
| 91 | + // expect(b.transcription.md).to.equal(`ahpoetikwe`); |
| 92 | + // expect(b.translation).to.equal(`maybe`); |
| 93 | + // }); |
| 94 | + // }); |
| 95 | + |
| 96 | + // context(`head`, function() { |
| 97 | + // it(`retains punctuation`, function() { |
| 98 | + // const entry = getTestEntry(this.data, this.test.title); |
| 99 | + // expect(entry.head.md).to.equal(`awinana?`); |
| 100 | + // expect(entry.head.syll).to.equal(`ᐊᐃᐧᓇᓇ?`); |
| 101 | + // }); |
| 102 | + // }); |
| 103 | + |
| 104 | + // context(`lemma`, function() { |
| 105 | + // it(`strips punctuation`, function() { |
| 106 | + // const { lemma } = getTestEntry(this.data, this.test.title); |
| 107 | + // expect(lemma.md).to.equal(`awinana`); |
| 108 | + // expect(lemma.syll).to.equal(`ᐊᐃᐧᓇᓇ`); |
| 109 | + // }); |
| 110 | + // }); |
| 111 | + |
| 112 | + // context(`notes`, function() { |
| 113 | + // it(`stores parentheticals as notes`, function() { |
| 114 | + // const { notes: [note] } = getTestEntry(this.data, this.test.title); |
| 115 | + // expect(note.text).to.equal(`as a tree`); |
| 116 | + // }); |
| 117 | + // }); |
| 118 | + |
| 119 | + // context(`original`, function() { |
| 120 | + // it(`stores the original data`, function() { |
| 121 | + // const entry = getTestEntry(this.data, this.test.title); |
| 122 | + // expect(entry.original.startsWith(`stores the original data\ta\tᐊ`)).to.be.true; |
| 123 | + // }); |
| 124 | + // }); |
| 125 | + |
| 126 | + // context(`output`, function() { |
| 127 | + |
| 128 | + // it(`returns an Array of entries`, function() { |
| 129 | + // expect(this.data).to.be.an(`Array`); |
| 130 | + // }); |
| 131 | + |
| 132 | + // it(`writes an NDJSON file`, async function() { |
| 133 | + |
| 134 | + // const text = await readFile(outputPath, `utf8`); |
| 135 | + // const lines = text.split(`\n`).filter(Boolean); |
| 136 | + |
| 137 | + // for (const line of lines) { |
| 138 | + // expect(() => JSON.parse(line)).not.to.throw(); |
| 139 | + // } |
| 140 | + |
| 141 | + // }); |
| 142 | + |
| 143 | + // }); |
| 144 | + |
| 145 | + // context(`Rapid Words`, function() { |
| 146 | + |
| 147 | + // it(`stores Rapid Words classes`, function() { |
| 148 | + // const { semanticDomains } = getTestEntry(this.data, this.test.title); |
| 149 | + // expect(semanticDomains).to.have.lengthOf(3); |
| 150 | + // expect(semanticDomains).to.include(`communication`); |
| 151 | + // expect(semanticDomains).to.include(`social_activity`); |
| 152 | + // expect(semanticDomains).to.include(`story`); |
| 153 | + // }); |
| 154 | + |
| 155 | + // it(`stores Rapid Words indices`, function() { |
| 156 | + // const { semanticIndices: [a, b, c] } = getTestEntry(this.data, this.test.title); |
| 157 | + // expect(a).to.equal(`3.5`); |
| 158 | + // expect(b).to.equal(`4.2`); |
| 159 | + // expect(c).to.equal(`3.5.4`); |
| 160 | + // }); |
| 161 | + |
| 162 | + // }); |
| 163 | + |
| 164 | +}); |
0 commit comments