@@ -72,6 +72,7 @@ describe('terminal module', function()
7272 position = ' botright' ,
7373 split_ratio = 0.5 ,
7474 enter_insert = true ,
75+ start_in_normal_mode = false ,
7576 hide_numbers = true ,
7677 hide_signcolumn = true ,
7778 },
@@ -196,6 +197,58 @@ describe('terminal module', function()
196197 end )
197198 end )
198199
200+ describe (' start_in_normal_mode option' , function ()
201+ it (' should not enter insert mode when start_in_normal_mode is true' , function ()
202+ -- Claude Code is not running (bufnr is nil)
203+ claude_code .claude_code .bufnr = nil
204+
205+ -- Set start_in_normal_mode to true
206+ config .window .start_in_normal_mode = true
207+
208+ -- Call toggle
209+ terminal .toggle (claude_code , config , git )
210+
211+ -- Check if startinsert was NOT called
212+ local startinsert_found = false
213+ for _ , cmd in ipairs (vim_cmd_calls ) do
214+ if cmd == ' startinsert' then
215+ startinsert_found = true
216+ break
217+ end
218+ end
219+
220+ assert .is_false (
221+ startinsert_found ,
222+ ' startinsert should not be called when start_in_normal_mode is true'
223+ )
224+ end )
225+
226+ it (' should enter insert mode when start_in_normal_mode is false' , function ()
227+ -- Claude Code is not running (bufnr is nil)
228+ claude_code .claude_code .bufnr = nil
229+
230+ -- Set start_in_normal_mode to false
231+ config .window .start_in_normal_mode = false
232+
233+ -- Call toggle
234+ terminal .toggle (claude_code , config , git )
235+
236+ -- Check if startinsert was called
237+ local startinsert_found = false
238+ for _ , cmd in ipairs (vim_cmd_calls ) do
239+ if cmd == ' startinsert' then
240+ startinsert_found = true
241+ break
242+ end
243+ end
244+
245+ assert .is_true (
246+ startinsert_found ,
247+ ' startinsert should be called when start_in_normal_mode is false'
248+ )
249+ end )
250+ end )
251+
199252 describe (' force_insert_mode' , function ()
200253 it (' should check insert mode conditions in terminal buffer' , function ()
201254 -- For this test, we'll just verify that the function can be called without error
@@ -206,7 +259,12 @@ describe('terminal module', function()
206259 bufnr = 1 ,
207260 },
208261 }
209- terminal .force_insert_mode (mock_claude_code )
262+ local mock_config = {
263+ window = {
264+ start_in_normal_mode = false ,
265+ },
266+ }
267+ terminal .force_insert_mode (mock_claude_code , mock_config )
210268 end )
211269
212270 assert .is_true (success , ' Force insert mode function should run without error' )
@@ -221,7 +279,12 @@ describe('terminal module', function()
221279 bufnr = 2 ,
222280 },
223281 }
224- terminal .force_insert_mode (mock_claude_code )
282+ local mock_config = {
283+ window = {
284+ start_in_normal_mode = false ,
285+ },
286+ }
287+ terminal .force_insert_mode (mock_claude_code , mock_config )
225288 end )
226289
227290 assert .is_true (success , ' Force insert mode function should run without error' )
0 commit comments