Skip to content

Commit 841d2a3

Browse files
committed
Fixed tests
1 parent 8b147c9 commit 841d2a3

File tree

6 files changed

+185
-11
lines changed

6 files changed

+185
-11
lines changed

lib/aggregate/aggregate.test.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -98,21 +98,23 @@ describe(`aggregate entries`, function() {
9898

9999
const { senses } = getTestEntry(this.entries, this.test.title);
100100

101-
expect(senses).to.have.lengthOf(2);
101+
expect(senses).to.have.lengthOf(3);
102102

103103
const sense1 = senses.find(sense => sense.definition === `s/he has a misconception`);
104104
const sense2 = senses.find(sense => sense.definition === `s/he is mistaken`);
105+
const sense3 = senses.find(sense => sense.definition === `He is mistaken about who that person is.`);
105106

106107
expect(sense1.sources).to.eql([`CW`]);
107108
expect(sense2.sources).to.eql([`CW`]);
109+
expect(sense3.sources).to.eql([`MD`]);
108110

109111
});
110112

111113
it(`matchType: dialect`, function() {
112114

113115
const { senses } = getTestEntry(this.entries, this.test.title);
114116

115-
expect(senses).to.have.lengthOf(2);
117+
expect(senses).to.have.lengthOf(3);
116118

117119
const sense1 = senses.find(sense => sense.definition === `squirrel`);
118120
const sense2 = senses.find(sense => sense.definition === `gopher`);
@@ -126,7 +128,7 @@ describe(`aggregate entries`, function() {
126128

127129
const { senses } = getTestEntry(this.entries, this.test.title);
128130

129-
expect(senses).to.have.lengthOf(1);
131+
expect(senses).to.have.lengthOf(2);
130132

131133
const [sense] = senses;
132134

@@ -139,7 +141,7 @@ describe(`aggregate entries`, function() {
139141

140142
const { senses } = getTestEntry(this.entries, this.test.title);
141143

142-
expect(senses).to.have.lengthOf(2);
144+
expect(senses).to.have.lengthOf(3);
143145

144146
const sense1 = senses.find(sense => sense.definition === `s/he puts s.o. (s.w.), s/he places s.o.`);
145147
const sense2 = senses.find(sense => sense.definition === `s/he sets s.o. down`);
@@ -153,7 +155,7 @@ describe(`aggregate entries`, function() {
153155

154156
const { senses } = getTestEntry(this.entries, this.test.title);
155157

156-
expect(senses).to.have.lengthOf(1);
158+
expect(senses).to.have.lengthOf(2);
157159

158160
const [sense] = senses;
159161

@@ -184,7 +186,7 @@ describe(`aggregate entries`, function() {
184186

185187
const { senses } = getTestEntry(this.entries, this.test.title);
186188

187-
expect(senses).to.have.lengthOf(1);
189+
expect(senses).to.have.lengthOf(2);
188190

189191
const [sense] = senses;
190192

@@ -197,7 +199,7 @@ describe(`aggregate entries`, function() {
197199

198200
const { senses } = getTestEntry(this.entries, this.test.title);
199201

200-
expect(senses).to.have.lengthOf(2);
202+
expect(senses).to.have.lengthOf(5);
201203

202204
const sense1 = senses.find(sense => sense.definition === `even, possibly`);
203205
const sense2 = senses.find(sense => sense.definition === `or, or else`);
@@ -211,7 +213,7 @@ describe(`aggregate entries`, function() {
211213

212214
const { senses } = getTestEntry(this.entries, this.test.title);
213215

214-
expect(senses).to.have.lengthOf(1);
216+
expect(senses).to.have.lengthOf(2);
215217

216218
const [sense] = senses;
217219

lib/convert/AECD.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class Entry {
2929
POS,
3030
Definition,
3131
Standardized_Definition,
32+
test,
3233
}) {
3334

3435
// if (Cross_References) {
@@ -77,7 +78,7 @@ class Entry {
7778
this.Plural_original = Plural_original;
7879
// this.semanticDomains = Entry.#splitSemanticDomains(RapidWordsClasses);
7980
// this.semanticIndices = Entry.#splitSemanticDomains(RapidWordsIndices);
80-
// this.test = test;
81+
this.test = test;
8182

8283
this.senses = Entry.#splitDefinition(Definition)
8384
.map(definition => ({

lib/convert/AECD.test.js

+164
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
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+
});

lib/convert/AECD.test.tsv

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
test AECD-original Standardized Analysis Syllabics Plural-original POS Definition Standardized Definition
2+
copies syllabics and standardized verbatim acahkos acâhkos acâhkos+N+A+Sg ᐊᒐᐦᑯᐢ acahkosak (na) A star.
3+
unknown âcimisowin âcimisowin âcimisowin+N+I+Sg ᐋᒋᒥᓱᐃᐧᐣ âcimisowina (ni) The act of confessing.
4+
unknown acimosis acimosis acimosis+N+A+Sg ᐊᒋᒧᓯᐢ acimosisak (na) A pup or a puppy; a newborn dog.
5+
unknown âcimostakewin âcimostâkêwin âcimostâkêwin+N+I+Sg ᐋᒋᒧᐢᑕᑫᐃᐧᐣ âcimostakewina (ni) The act of providing information; storytelling; being informational.
6+
unknown âcimsostâkewin âcimisostâkêwin âcimisostâkêwin+N+I+Sg ᐋᒋᒼᓱᐢᑖᑫᐃᐧᐣ âcimsostâkewina (ni) A confession to a priest.
7+
unknown acônikewin +? ᐊᒎᓂᑫᐃᐧᐣ acônikewina (ni) An abbreviation.

lib/convert/CW.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ describe(`CW conversion script`, () => {
137137
const { proto, sro, syll } = lemma;
138138

139139
expect(proto).to.equal(`acicipaýihow`);
140-
expect(sro).to.equal(`acicipayihow`);
140+
expect(sro).to.equal(`acicipaýihow`);
141141
expect(syll).to.equal(`ᐊᒋᒋᐸᔨᐦᐅᐤ`);
142142

143143
});

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"build:relax-fst": "python lib/utilities/mini-lfs-client.py UAlbertaALTLab cree-intelligent-dictionary src/crkeng/resources/fst/crk-relaxed-analyzer-for-dictionary.hfstol",
2929
"build:strict-fst": "python lib/utilities/mini-lfs-client.py UAlbertaALTLab cree-intelligent-dictionary src/crkeng/resources/fst/crk-strict-analyzer-for-dictionary.hfstol",
3030
"clear": "node bin/clearDatabase.js",
31-
"test": "mocha --ignore=Toolbox.test.js lib/**/*.test.js test/*.test.js",
31+
"test": "mocha --ignore=Toolbox.test.js \"lib/**/*.test.js\" \"test/*.test.js\"",
3232
"test:build": "mocha lib/test/testBuild.js"
3333
},
3434
"bin": {

0 commit comments

Comments
 (0)