@@ -267,6 +267,24 @@ Array.valueOf
267
267
" Array.toLocaleString"
268
268
" Array.valueOf" ))))
269
269
270
+ (ert-deftest js-comint--process-completion-output/test-multiline-prefix ()
271
+ " Completion when there is a '...' prefix."
272
+ (should
273
+ (equal
274
+ (js-comint--process-completion-output
275
+ " Array.
276
+ Array.__proto__ Array.hasOwnProperty Array.isPrototypeOf Array.propertyIsEnumerable Array.toLocaleString
277
+ Array.valueOf
278
+
279
+ [1G[0J... Array.[11G"
280
+ " Array." )
281
+ '(" Array.__proto__"
282
+ " Array.hasOwnProperty"
283
+ " Array.isPrototypeOf"
284
+ " Array.propertyIsEnumerable"
285
+ " Array.toLocaleString"
286
+ " Array.valueOf" ))))
287
+
270
288
(ert-deftest js-comint--async-output-filter/test-no-callbacks ()
271
289
" Output should be kept when no callbacks are active."
272
290
(with-temp-buffer
@@ -345,11 +363,16 @@ Array.valueOf
345
363
" Output should be saved until string match, then fail."
346
364
(with-mock
347
365
(stub js-comint--callback-active-p => 't )
348
- (mock (process-send-string * * ) :times 2 )
366
+ ; ; 1 - complete foo
367
+ ; ; 2 - finished test " \b"
368
+ ; ; 3 - clear ""
369
+ (mock (process-send-string * * ) :times 3 )
349
370
(with-temp-buffer
350
371
; ; callback should be called with nil
351
372
(js-comint--get-completion-async " foo" (lambda (arg ) (should-not arg)))
352
- (dolist (output '(" f" " oo" ))
373
+ (dolist (output '(" f" " oo" ; ; output in chunks
374
+ " [1G[0J> foo[3G" ; ; response to " \b"
375
+ ))
353
376
(should (string-empty-p (js-comint--async-output-filter output))))
354
377
; ; clear should be called
355
378
(should (equal (plist-get (car js-comint--completion-callbacks) :type )
@@ -359,11 +382,18 @@ Array.valueOf
359
382
" When completion fails on something that looks like an object don't hang."
360
383
(with-mock
361
384
(stub js-comint--callback-active-p => 't )
362
- (mock (process-send-string * * ) :times 3 )
385
+ ; ; 1 - complete
386
+ ; ; 2 - send another \t
387
+ ; ; 3 - finished test " \b"
388
+ ; ; 4 - clear
389
+ (mock (process-send-string * * ) :times 4 )
363
390
(with-temp-buffer
364
391
; ; callback should be called with nil
365
- (js-comint--get-completion-async " Array." (lambda (arg ) (should-not arg)))
366
- (dolist (output '(" A" " rray." " Array." ))
392
+ (js-comint--get-completion-async " scrog." (lambda (arg ) (should-not arg)))
393
+ (dolist (output '(" s" " crog." ; ; output in chunks
394
+ " scrog." ; ; response to repeat \t
395
+ " [1G[0J> scrog.[3G" ; ; response to " \b"
396
+ ))
367
397
(should (string-empty-p (js-comint--async-output-filter output))))
368
398
; ; clear should be called
369
399
(should (equal (plist-get (car js-comint--completion-callbacks) :type )
@@ -379,7 +409,9 @@ Array.valueOf
379
409
(js-comint--get-completion-async " foo"
380
410
(lambda (arg ) (error " Broken user callback " )))
381
411
; ; after output the erroring callback is called with nil
382
- (dolist (output '(" f" " oo" ))
412
+ (dolist (output '(" f" " oo"
413
+ " [1G[0J> foo[3G" ; ; response to " \b"
414
+ ))
383
415
(should (string-empty-p (js-comint--async-output-filter output))))
384
416
; ; clear should be called
385
417
(should (equal (plist-get (car js-comint--completion-callbacks) :type )
0 commit comments