@@ -34,7 +34,7 @@ describe("ClaudeCodeSend Command Range Functionality", function()
34
34
notify = spy .new (function () end ),
35
35
log = { levels = { ERROR = 1 , WARN = 2 , INFO = 3 } },
36
36
deepcopy = function (t ) return t end ,
37
- tbl_deep_extend = function (behavior , ...)
37
+ tbl_deep_extend = function (behavior , ...)
38
38
local result = {}
39
39
for _ , tbl in ipairs ({... }) do
40
40
for k , v in pairs (tbl ) do
@@ -74,7 +74,7 @@ describe("ClaudeCodeSend Command Range Functionality", function()
74
74
}
75
75
76
76
local mock_config = {
77
- apply = function (opts )
77
+ apply = function (opts )
78
78
return {
79
79
auto_start = false ,
80
80
track_selection = true ,
@@ -114,7 +114,7 @@ describe("ClaudeCodeSend Command Range Functionality", function()
114
114
-- Load and setup claudecode
115
115
claudecode = require (" claudecode" )
116
116
claudecode .setup ({})
117
-
117
+
118
118
-- Manually set server state for testing
119
119
claudecode .state .server = mock_server
120
120
claudecode .state .port = 12345
@@ -128,7 +128,7 @@ describe("ClaudeCodeSend Command Range Functionality", function()
128
128
describe (" ClaudeCodeSend command" , function ()
129
129
it (" should be registered with range support" , function ()
130
130
assert .spy (_G .vim .api .nvim_create_user_command ).was_called ()
131
-
131
+
132
132
-- Find the ClaudeCodeSend command call
133
133
local calls = _G .vim .api .nvim_create_user_command .calls
134
134
local claudecode_send_call = nil
@@ -138,107 +138,107 @@ describe("ClaudeCodeSend Command Range Functionality", function()
138
138
break
139
139
end
140
140
end
141
-
141
+
142
142
assert (claudecode_send_call ~= nil , " ClaudeCodeSend command should be registered" )
143
143
assert (claudecode_send_call .vals [3 ].range == true , " ClaudeCodeSend should support ranges" )
144
144
end )
145
145
146
146
it (" should pass range information to selection module when range is provided" , function ()
147
147
assert (command_callback ~= nil , " Command callback should be set" )
148
-
148
+
149
149
-- Simulate command called with range
150
150
local opts = {
151
151
range = 2 ,
152
152
line1 = 5 ,
153
153
line2 = 8
154
154
}
155
-
155
+
156
156
command_callback (opts )
157
-
157
+
158
158
assert .spy (mock_selection_module .send_at_mention_for_visual_selection ).was_called ()
159
159
assert (mock_selection_module .last_call .line1 == 5 )
160
160
assert (mock_selection_module .last_call .line2 == 8 )
161
161
end )
162
162
163
163
it (" should not pass range information when range is 0" , function ()
164
164
assert (command_callback ~= nil , " Command callback should be set" )
165
-
165
+
166
166
-- Simulate command called without range
167
167
local opts = {
168
168
range = 0 ,
169
169
line1 = 1 ,
170
170
line2 = 1
171
171
}
172
-
172
+
173
173
command_callback (opts )
174
-
174
+
175
175
assert .spy (mock_selection_module .send_at_mention_for_visual_selection ).was_called ()
176
176
assert (mock_selection_module .last_call .line1 == nil )
177
177
assert (mock_selection_module .last_call .line2 == nil )
178
178
end )
179
179
180
180
it (" should not pass range information when range is nil" , function ()
181
181
assert (command_callback ~= nil , " Command callback should be set" )
182
-
182
+
183
183
-- Simulate command called without range
184
184
local opts = {}
185
-
185
+
186
186
command_callback (opts )
187
-
187
+
188
188
assert .spy (mock_selection_module .send_at_mention_for_visual_selection ).was_called ()
189
189
assert (mock_selection_module .last_call .line1 == nil )
190
190
assert (mock_selection_module .last_call .line2 == nil )
191
191
end )
192
192
193
193
it (" should exit visual mode and focus terminal on successful send" , function ()
194
194
assert (command_callback ~= nil , " Command callback should be set" )
195
-
195
+
196
196
local opts = {
197
197
range = 2 ,
198
198
line1 = 5 ,
199
199
line2 = 8
200
200
}
201
-
201
+
202
202
command_callback (opts )
203
-
203
+
204
204
assert .spy (_G .vim .api .nvim_feedkeys ).was_called ()
205
205
assert .spy (mock_terminal .open ).was_called ()
206
206
end )
207
207
208
208
it (" should handle server not running" , function ()
209
209
assert (command_callback ~= nil , " Command callback should be set" )
210
-
210
+
211
211
-- Simulate server not running
212
212
claudecode .state .server = nil
213
-
213
+
214
214
local opts = {
215
215
range = 2 ,
216
216
line1 = 5 ,
217
217
line2 = 8
218
218
}
219
-
219
+
220
220
command_callback (opts )
221
-
221
+
222
222
assert .spy (_G .vim .notify ).was_called ()
223
223
assert .spy (mock_selection_module .send_at_mention_for_visual_selection ).was_not_called ()
224
224
end )
225
225
226
226
it (" should handle selection module failure" , function ()
227
227
assert (command_callback ~= nil , " Command callback should be set" )
228
-
228
+
229
229
-- Mock selection module to return false
230
230
mock_selection_module .send_at_mention_for_visual_selection = spy .new (function ()
231
231
return false
232
232
end )
233
-
233
+
234
234
local opts = {
235
235
range = 2 ,
236
236
line1 = 5 ,
237
237
line2 = 8
238
238
}
239
-
239
+
240
240
command_callback (opts )
241
-
241
+
242
242
assert .spy (mock_selection_module .send_at_mention_for_visual_selection ).was_called ()
243
243
-- Should not exit visual mode or focus terminal on failure
244
244
assert .spy (_G .vim .api .nvim_feedkeys ).was_not_called ()
0 commit comments