diff --git a/app/__tests__/builderReducer.test.ts b/app/__tests__/builderReducer.test.ts index f33d1c63..0a2b53ab 100644 --- a/app/__tests__/builderReducer.test.ts +++ b/app/__tests__/builderReducer.test.ts @@ -95,6 +95,22 @@ test('home and end keyboard events are recognized', () => { expect(fromKeyString('End')).toEqual({ k: KeyK.End }); }); +/* +I D █ +I ^ █ +█ █ █ + +^ This cell represents the rebus 'PAD'. +*/ +test('short word warning', () => { + const state = getState(['I', 'D', '.', 'I', 'PAD', '.', '.', '.', '.'], {}); + expect(builderReducer(state, publish).publishWarnings).toMatchInlineSnapshot(` + [ + "Some words are only two letters long (ID, II)", + ] + `); +}); + test('basic enum warnings', () => { const state = getState(['a', 'b', 'c', 'g', '', '', 'd', 'e', 'f'], { abc: 'test with good enum (3)', diff --git a/app/reducers/builderUtils.ts b/app/reducers/builderUtils.ts index adb39ad0..8401139d 100644 --- a/app/reducers/builderUtils.ts +++ b/app/reducers/builderUtils.ts @@ -31,7 +31,7 @@ export function validateGrid(state: BuilderState) { } for (const [i, entry] of state.grid.entries.entries()) { - if (entry.cells.length <= 2) { + if (entry.completedWord && entry.completedWord.length <= 2) { hasNoShortWords = false; } for (let j = 0; j < state.grid.entries.length; j += 1) { @@ -84,7 +84,7 @@ export function getWarningStats(state: BuilderState) { const shortWords = new Set(); for (const [i, entry] of entries.entries()) { - if (entry.cells.length <= 2) { + if (entry.completedWord && entry.completedWord.length <= 2) { shortWords.add(entryWord(grid, i)); } }