The original message for no input ("Seed phrase of length 1 can't be arranged into a grid") does not make sense.
*/
export function main() {
const input = prompt("Seed phrase:");
+ if (input === "") {
+ console.error(
+ "%c\nNo input provided. Enter a seed phrase to check permutations.",
+ "color: red",
+ );
+ Deno.exit(0);
+ }
const words = parseInput(input);
const factors = getLowerFactors(words.length);
if (factors.length === 0) {
consoleSpy.restore();
promptStub.restore();
});
+
+Deno.test("main exits cleanly on no input", () => {
+ const consoleSpy = spy(console, "error");
+ const promptStub = stub(
+ globalThis,
+ "prompt",
+ () => "",
+ );
+
+ assertThrows(main);
+ assertSpyCalls(consoleSpy, 1);
+
+ consoleSpy.restore();
+ promptStub.restore();
+});