* A Prompter that replays a canned queue of answers and captures every line * the wizard writes. Tests push answers in order; step functions consume * them via prompter.ask().
(answers: string[])
| 24 | * them via prompter.ask(). |
| 25 | */ |
| 26 | function mockPrompter(answers: string[]): Prompter & { lines: string[]; remaining: () => number } { |
| 27 | const queue = [...answers]; |
| 28 | const lines: string[] = []; |
| 29 | return { |
| 30 | ask: async (question: string) => { |
| 31 | if (queue.length === 0) { |
| 32 | throw new Error(`mockPrompter: ran out of answers at question "${question}"`); |
| 33 | } |
| 34 | return queue.shift()!; |
| 35 | }, |
| 36 | write: (line: string) => { |
| 37 | lines.push(line); |
| 38 | }, |
| 39 | lines, |
| 40 | remaining: () => queue.length, |
| 41 | }; |
| 42 | } |
| 43 | |
| 44 | function fakeSeed(overrides: Partial<IdeasSeed> = {}): IdeasSeed { |
| 45 | return { |
no outgoing calls
no test coverage detected