fix(web): address most PR review concerns

Covers unit test names, describe => it for one case, and consistency in an error case between spurs and roots.
This commit is contained in:
Joshua Horton 2026-03-11 08:14:58 -05:00
parent 052f1f1f70
commit eb958fa4de
3 changed files with 7 additions and 3 deletions

View file

@ -68,7 +68,7 @@ export class SearchQuotientRoot implements SearchQuotientNode {
*/
public handleNextNode(): PathResult {
if(this.hasBeenProcessed) {
return null;
return { type: 'none' };
}
this.hasBeenProcessed = true;

View file

@ -171,6 +171,10 @@ export abstract class SearchQuotientSpur implements SearchQuotientNode {
// spaces are in sequence here.
// `this` = head 'space'.
public merge(space: SearchQuotientNode): SearchQuotientNode {
if(this.model != space.model) {
throw new Error("Cannot merge search graphs based on different LexicalModels");
}
// Head node for the incoming path is empty, so skip it.
if(space.parents.length == 0 || space instanceof SearchQuotientRoot) {
return this;

View file

@ -23,7 +23,7 @@ import TrieModel = models.TrieModel;
const testModel = new TrieModel(jsonFixture('models/tries/english-1000'));
const altModel = new TrieModel(jsonFixture('models/tries/accented'));
describe('SearchQuotientSpur', () => {
describe('SearchQuotientRoot', () => {
describe('constructor', () => {
it('initializes from a lexical model', () => {
const path = new SearchQuotientRoot(testModel);
@ -44,7 +44,7 @@ describe('SearchQuotientSpur', () => {
assert.deepEqual(constituentPaths(path), []);
});
describe('.isSameNode returns true for separate instance on same model', () => {
it('.isSameNode returns true for separate instance on same model', () => {
const root1 = new SearchQuotientRoot(testModel);
const root2 = new SearchQuotientRoot(testModel);