@@ -234,25 +234,31 @@ describe(".clear", function()
234234 it (" sends 'clear' to the terminal on Unix" , function ()
235235 --- @diagnostic disable-next-line : duplicate-set-field
236236 utils .is_windows = function () return false end
237- local term = Terminal :new ()
237+ local term = Terminal :new ():start ()
238+ local spy_chansend = spy .on (vim .fn , " chansend" )
238239
239240 send .clear (term )
240241 vim .wait (100 )
241242
242- local lines = vim .api .nvim_buf_get_lines (term :get_state (" bufnr" ), 0 , - 1 , false )
243- assert .is_true (vim .tbl_contains (lines , " clear" ))
243+ assert .spy (spy_chansend ).was_called_with (
244+ term :get_state (" job_id" ),
245+ { " clear" , " " }
246+ )
244247 end )
245248
246249 it (" sends 'cls' to the terminal on Windows" , function ()
247250 --- @diagnostic disable-next-line : duplicate-set-field
248251 utils .is_windows = function () return true end
249252 local term = Terminal :new ():start ()
253+ local spy_chansend = spy .on (vim .fn , " chansend" )
250254
251255 send .clear (term )
252256 vim .wait (100 )
253257
254- local lines = vim .api .nvim_buf_get_lines (term :get_state (" bufnr" ), 0 , - 1 , false )
255- assert .is_true (vim .tbl_contains (lines , " cls" ))
258+ assert .spy (spy_chansend ).was_called_with (
259+ term :get_state (" job_id" ),
260+ { " cls" , " " }
261+ )
256262 end )
257263
258264 it (" delegates action option to send" , function ()
0 commit comments