-
-
Notifications
You must be signed in to change notification settings - Fork 142
Expand file tree
/
Copy pathconstituentPaths.tests.ts
More file actions
45 lines (36 loc) · 1.73 KB
/
Copy pathconstituentPaths.tests.ts
File metadata and controls
45 lines (36 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* Keyman is copyright (C) SIL Global. MIT License.
*
* Created by jahorton on 2026-03-10
*
* This file adds unit tests for unit-test helper functions validating
* the correction-search modules of the Keyman predictive-text engine.
*/
import { assert } from 'chai';
import { constituentPaths } from "./constituentPaths.js";
import { buildCantLinearFixture } from './buildCantLinearFixture.js';
import { buildAlphabeticClusterFixtures } from './buildAlphabeticClusteredFixture.js';
describe('constituentPaths', () => {
it('includes a single entry array when all parents are SearchQuotientSpurs', () => {
const { paths } = buildCantLinearFixture();
const finalPath = paths[4];
assert.equal(constituentPaths(finalPath).length, 1);
const pathSequence = constituentPaths(finalPath)[0];
assert.equal(pathSequence.length, 4); // 4 inputs; does not include root node
assert.sameOrderedMembers(pathSequence, paths.slice(1));
});
it('properly enumerates child paths when encountering SearchCluster ancestors', () => {
const fixture = buildAlphabeticClusterFixtures();
const finalPath = fixture.paths[4].path_k4c6;
// The longest SearchPath at the end of that fixture's set is based on a
// lead-in cluster; all variants of that should be included.
assert.equal(constituentPaths(finalPath).length, constituentPaths(fixture.clusters.cluster_k3c4).length);
// That cluster holds the different potential penultimate paths;
// finalPath's inputs are added directly after any variation that may be
// output from the cluster.
assert.sameDeepMembers(constituentPaths(finalPath), constituentPaths(fixture.clusters.cluster_k3c4).map((p) => {
p.push(finalPath);
return p;
}));
});
});