@@ -240,3 +240,61 @@ Array.valueOf
240
240
(should (string-empty-p res)))
241
241
; ; the output should not be accumulated
242
242
(should (string-empty-p js-comint--completion-output))))
243
+
244
+ (ert-deftest js-comint--completion-filter/test-no-completion ()
245
+ " Output should be saved until string match, then fail."
246
+ (with-mock
247
+ (mock (ignore nil )) ; ; must be called
248
+ (mock (js-comint--clear-repl-input))
249
+ (with-temp-buffer
250
+ (js-comint--reset-completion-state)
251
+ (setq js-comint--post-completion-cb #'ignore
252
+ js-comint--completion-prefix " foo" )
253
+
254
+ ; ; each should be empty
255
+ (dolist (res (list (js-comint--completion-filter " f" )
256
+ (js-comint--completion-filter " oo" )))
257
+ (should (string-empty-p res)))
258
+ ; ; callback should be called with nil
259
+ ; ; clear should be called
260
+ ; ; then the the flag should be cleared
261
+ (should-not js-comint--post-completion-cb))))
262
+
263
+ (ert-deftest js-comint--completion-filter/test-list-completion ()
264
+ " Output should be saved until control char, then list returned."
265
+ (with-mock
266
+ ; ; callback should be called with completions
267
+ (mock (ignore '(" foobar" " foobaz" )))
268
+ (mock (js-comint--clear-repl-input))
269
+ (with-temp-buffer
270
+ (js-comint--reset-completion-state)
271
+ (setq js-comint--post-completion-cb #'ignore
272
+ js-comint--completion-prefix " foo" )
273
+
274
+ ; ; each should be empty
275
+ (dolist (res (list (js-comint--completion-filter " foobar foobaz" )
276
+ (js-comint--completion-filter " [1G[0J> foo[3G" )))
277
+ (should (string-empty-p res)))
278
+
279
+ ; ; clear should be called
280
+ ; ; then the the flag should be cleared
281
+ (should-not js-comint--post-completion-cb))))
282
+
283
+ (ert-deftest js-comint--completion-filter/test-double-tab ()
284
+ " When completing object properties, send another tab to get completion."
285
+ (with-mock
286
+ (stub js-comint-get-process)
287
+ (mock (comint-send-string * " \t " ))
288
+ (with-temp-buffer
289
+ (js-comint--reset-completion-state)
290
+ (setq js-comint--post-completion-cb #'ignore
291
+ js-comint--completion-prefix " foo." )
292
+
293
+ ; ; each should be empty
294
+ (dolist (res (list (js-comint--completion-filter " f" )
295
+ (js-comint--completion-filter " oo." )))
296
+ (should (string-empty-p res)))
297
+ ; ; after sending tab should be ready to recieve completion
298
+ (should js-comint--post-completion-cb)
299
+ (should (equal js-comint--completion-prefix " foo." ))
300
+ (should (equal js-comint--completion-output " foo." )))))
0 commit comments