@@ -9,16 +9,16 @@ local T = MiniTest.new_set({
99 child .lua ([[
1010 -- Setup commands
1111 require('eca.commands').setup()
12-
12+
1313 -- Instantiate state singleton
1414 _G.State = require('eca.state').new()
15-
15+
1616 -- Mock vim.ui.select for testing
1717 _G.selected_choice = nil
1818 _G.shown_items = nil
1919 _G.shown_prompt = nil
2020 _G.original_select = vim.ui.select
21-
21+
2222 _G.mock_select = function(choice)
2323 _G.selected_choice = choice
2424 vim.ui.select = function(items, opts, on_choice)
@@ -27,7 +27,7 @@ local T = MiniTest.new_set({
2727 on_choice(choice)
2828 end
2929 end
30-
30+
3131 _G.restore_select = function()
3232 vim.ui.select = _G.original_select
3333 end
@@ -54,14 +54,14 @@ T["EcaChatSelectModel"]["updates state when model selected"] = function()
5454 child .lua ([[
5555 _G.State.config.models.list = { "model1", "model2", "model3" }
5656 _G.State.config.models.selected = "model1"
57-
57+
5858 -- Mock vim.ui.select to auto-select model2
5959 _G.mock_select("model2")
6060 ]] )
61-
61+
6262 -- Execute command
6363 child .cmd (" EcaChatSelectModel" )
64-
64+
6565 -- Check that state was updated
6666 eq (child .lua_get (" _G.State.config.models.selected" ), " model2" )
6767end
@@ -71,14 +71,14 @@ T["EcaChatSelectModel"]["handles nil selection"] = function()
7171 child .lua ([[
7272 _G.State.config.models.list = { "model1", "model2" }
7373 _G.State.config.models.selected = "model1"
74-
74+
7575 -- Mock vim.ui.select to return nil (user cancelled)
7676 _G.mock_select(nil)
7777 ]] )
78-
78+
7979 -- Execute command
8080 child .cmd (" EcaChatSelectModel" )
81-
81+
8282 -- Check that state was NOT updated (still model1)
8383 eq (child .lua_get (" _G.State.config.models.selected" ), " model1" )
8484end
@@ -87,14 +87,14 @@ T["EcaChatSelectModel"]["displays all available models"] = function()
8787 -- Setup models list
8888 child .lua ([[
8989 _G.State.config.models.list = { "gpt-4", "gpt-3.5-turbo", "claude-3" }
90-
90+
9191 -- Mock vim.ui.select to capture the items shown
9292 _G.mock_select(nil)
9393 ]] )
94-
94+
9595 -- Execute command
9696 child .cmd (" EcaChatSelectModel" )
97-
97+
9898 -- Verify all models were shown
9999 local shown_items = child .lua_get (" _G.shown_items" )
100100 eq (shown_items [1 ], " gpt-4" )
@@ -116,14 +116,14 @@ T["EcaChatSelectBehavior"]["updates state when behavior selected"] = function()
116116 child .lua ([[
117117 _G.State.config.behaviors.list = { "helpful", "creative", "concise" }
118118 _G.State.config.behaviors.selected = "helpful"
119-
119+
120120 -- Mock vim.ui.select to auto-select creative
121121 _G.mock_select("creative")
122122 ]] )
123-
123+
124124 -- Execute command
125125 child .cmd (" EcaChatSelectBehavior" )
126-
126+
127127 -- Check that state was updated
128128 eq (child .lua_get (" _G.State.config.behaviors.selected" ), " creative" )
129129end
@@ -133,14 +133,14 @@ T["EcaChatSelectBehavior"]["handles nil selection"] = function()
133133 child .lua ([[
134134 _G.State.config.behaviors.list = { "helpful", "creative" }
135135 _G.State.config.behaviors.selected = "helpful"
136-
136+
137137 -- Mock vim.ui.select to return nil (user cancelled)
138138 _G.mock_select(nil)
139139 ]] )
140-
140+
141141 -- Execute command
142142 child .cmd (" EcaChatSelectBehavior" )
143-
143+
144144 -- Check that state was NOT updated (still helpful)
145145 eq (child .lua_get (" _G.State.config.behaviors.selected" ), " helpful" )
146146end
@@ -149,14 +149,14 @@ T["EcaChatSelectBehavior"]["displays all available behaviors"] = function()
149149 -- Setup behaviors list
150150 child .lua ([[
151151 _G.State.config.behaviors.list = { "helpful", "creative", "concise", "technical" }
152-
152+
153153 -- Mock vim.ui.select to capture the items shown
154154 _G.mock_select(nil)
155155 ]] )
156-
156+
157157 -- Execute command
158158 child .cmd (" EcaChatSelectBehavior" )
159-
159+
160160 -- Verify all behaviors were shown
161161 local shown_items = child .lua_get (" _G.shown_items" )
162162 eq (shown_items [1 ], " helpful" )
@@ -165,73 +165,4 @@ T["EcaChatSelectBehavior"]["displays all available behaviors"] = function()
165165 eq (shown_items [4 ], " technical" )
166166end
167167
168- -- Test State update methods
169- T [" State" ] = MiniTest .new_set ()
170-
171- T [" State" ][" update_selected_model updates config" ] = function ()
172- child .lua ([[
173- _G.State.config.models.list = { "model1", "model2" }
174- _G.State.config.models.selected = "model1"
175-
176- _G.State:update_selected_model("model2")
177- ]] )
178-
179- eq (child .lua_get (" _G.State.config.models.selected" ), " model2" )
180- end
181-
182- T [" State" ][" update_selected_model handles nil" ] = function ()
183- child .lua ([[
184- _G.State.config.models.selected = "model1"
185-
186- -- Should not update if nil is passed
187- _G.State:update_selected_model(nil)
188- ]] )
189-
190- eq (child .lua_get (" _G.State.config.models.selected" ), " model1" )
191- end
192-
193- T [" State" ][" update_selected_model handles non-string" ] = function ()
194- child .lua ([[
195- _G.State.config.models.selected = "model1"
196-
197- -- Should not update if non-string is passed
198- _G.State:update_selected_model(123)
199- ]] )
200-
201- eq (child .lua_get (" _G.State.config.models.selected" ), " model1" )
202- end
203-
204- T [" State" ][" update_selected_behavior updates config" ] = function ()
205- child .lua ([[
206- _G.State.config.behaviors.list = { "helpful", "creative" }
207- _G.State.config.behaviors.selected = "helpful"
208-
209- _G.State:update_selected_behavior("creative")
210- ]] )
211-
212- eq (child .lua_get (" _G.State.config.behaviors.selected" ), " creative" )
213- end
214-
215- T [" State" ][" update_selected_behavior handles nil" ] = function ()
216- child .lua ([[
217- _G.State.config.behaviors.selected = "helpful"
218-
219- -- Should not update if nil is passed
220- _G.State:update_selected_behavior(nil)
221- ]] )
222-
223- eq (child .lua_get (" _G.State.config.behaviors.selected" ), " helpful" )
224- end
225-
226- T [" State" ][" update_selected_behavior handles non-string" ] = function ()
227- child .lua ([[
228- _G.State.config.behaviors.selected = "helpful"
229-
230- -- Should not update if non-string is passed
231- _G.State:update_selected_behavior(123)
232- ]] )
233-
234- eq (child .lua_get (" _G.State.config.behaviors.selected" ), " helpful" )
235- end
236-
237168return T
0 commit comments