@@ -86,6 +86,16 @@ describe("prepareRunConfig", () => {
8686 ) ;
8787 } ) ;
8888
89+ test ( "should include fallback model in command arguments" , ( ) => {
90+ const options : ClaudeOptions = {
91+ fallbackModel : "claude-sonnet-4-20250514" ,
92+ } ;
93+ const prepared = prepareRunConfig ( "/tmp/test-prompt.txt" , options ) ;
94+
95+ expect ( prepared . claudeArgs ) . toContain ( "--fallback-model" ) ;
96+ expect ( prepared . claudeArgs ) . toContain ( "claude-sonnet-4-20250514" ) ;
97+ } ) ;
98+
8999 test ( "should use provided prompt path" , ( ) => {
90100 const options : ClaudeOptions = { } ;
91101 const prepared = prepareRunConfig ( "/custom/prompt/path.txt" , options ) ;
@@ -103,6 +113,7 @@ describe("prepareRunConfig", () => {
103113 expect ( prepared . claudeArgs ) . not . toContain ( "--mcp-config" ) ;
104114 expect ( prepared . claudeArgs ) . not . toContain ( "--system-prompt" ) ;
105115 expect ( prepared . claudeArgs ) . not . toContain ( "--append-system-prompt" ) ;
116+ expect ( prepared . claudeArgs ) . not . toContain ( "--fallback-model" ) ;
106117 } ) ;
107118
108119 test ( "should preserve order of claude arguments" , ( ) => {
@@ -124,6 +135,40 @@ describe("prepareRunConfig", () => {
124135 ] ) ;
125136 } ) ;
126137
138+ test ( "should preserve order with all options including fallback model" , ( ) => {
139+ const options : ClaudeOptions = {
140+ allowedTools : "Bash,Read" ,
141+ disallowedTools : "Write" ,
142+ maxTurns : "3" ,
143+ mcpConfig : "/path/to/config.json" ,
144+ systemPrompt : "You are a helpful assistant" ,
145+ appendSystemPrompt : "Be concise" ,
146+ fallbackModel : "claude-sonnet-4-20250514" ,
147+ } ;
148+ const prepared = prepareRunConfig ( "/tmp/test-prompt.txt" , options ) ;
149+
150+ expect ( prepared . claudeArgs ) . toEqual ( [
151+ "-p" ,
152+ "--verbose" ,
153+ "--output-format" ,
154+ "stream-json" ,
155+ "--allowedTools" ,
156+ "Bash,Read" ,
157+ "--disallowedTools" ,
158+ "Write" ,
159+ "--max-turns" ,
160+ "3" ,
161+ "--mcp-config" ,
162+ "/path/to/config.json" ,
163+ "--system-prompt" ,
164+ "You are a helpful assistant" ,
165+ "--append-system-prompt" ,
166+ "Be concise" ,
167+ "--fallback-model" ,
168+ "claude-sonnet-4-20250514" ,
169+ ] ) ;
170+ } ) ;
171+
127172 describe ( "maxTurns validation" , ( ) => {
128173 test ( "should accept valid maxTurns value" , ( ) => {
129174 const options : ClaudeOptions = { maxTurns : "5" } ;
@@ -154,6 +199,36 @@ describe("prepareRunConfig", () => {
154199 } ) ;
155200 } ) ;
156201
202+ describe ( "timeoutMinutes validation" , ( ) => {
203+ test ( "should accept valid timeoutMinutes value" , ( ) => {
204+ const options : ClaudeOptions = { timeoutMinutes : "15" } ;
205+ expect ( ( ) =>
206+ prepareRunConfig ( "/tmp/test-prompt.txt" , options ) ,
207+ ) . not . toThrow ( ) ;
208+ } ) ;
209+
210+ test ( "should throw error for non-numeric timeoutMinutes" , ( ) => {
211+ const options : ClaudeOptions = { timeoutMinutes : "abc" } ;
212+ expect ( ( ) => prepareRunConfig ( "/tmp/test-prompt.txt" , options ) ) . toThrow (
213+ "timeoutMinutes must be a positive number, got: abc" ,
214+ ) ;
215+ } ) ;
216+
217+ test ( "should throw error for negative timeoutMinutes" , ( ) => {
218+ const options : ClaudeOptions = { timeoutMinutes : "-5" } ;
219+ expect ( ( ) => prepareRunConfig ( "/tmp/test-prompt.txt" , options ) ) . toThrow (
220+ "timeoutMinutes must be a positive number, got: -5" ,
221+ ) ;
222+ } ) ;
223+
224+ test ( "should throw error for zero timeoutMinutes" , ( ) => {
225+ const options : ClaudeOptions = { timeoutMinutes : "0" } ;
226+ expect ( ( ) => prepareRunConfig ( "/tmp/test-prompt.txt" , options ) ) . toThrow (
227+ "timeoutMinutes must be a positive number, got: 0" ,
228+ ) ;
229+ } ) ;
230+ } ) ;
231+
157232 describe ( "custom environment variables" , ( ) => {
158233 test ( "should parse empty claudeEnv correctly" , ( ) => {
159234 const options : ClaudeOptions = { claudeEnv : "" } ;
0 commit comments