aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lisp/erc/erc-goodies-tests.el81
1 files changed, 81 insertions, 0 deletions
diff --git a/test/lisp/erc/erc-goodies-tests.el b/test/lisp/erc/erc-goodies-tests.el
index 46fcf82401b..a1f53c5bf88 100644
--- a/test/lisp/erc/erc-goodies-tests.el
+++ b/test/lisp/erc/erc-goodies-tests.el
@@ -250,4 +250,85 @@
250 (when noninteractive 250 (when noninteractive
251 (kill-buffer))))) 251 (kill-buffer)))))
252 252
253
254;; Among other things, this test also asserts that a local module's
255;; minor-mode toggle is allowed to disable its mode variable as
256;; needed.
257
258(ert-deftest erc-keep-place-indicator-mode ()
259 ;; FIXME remove after adding
260 (unless (fboundp 'erc--initialize-markers)
261 (ert-skip "Missing required function"))
262 (with-current-buffer (get-buffer-create "*erc-keep-place-indicator-mode*")
263 (erc-mode)
264 (erc--initialize-markers (point) nil)
265 (let ((assert-off
266 (lambda ()
267 (should-not erc-keep-place-indicator-mode)
268 (should-not (local-variable-p 'window-configuration-change-hook))
269 (should-not erc--keep-place-indicator-overlay)))
270 (assert-on
271 (lambda ()
272 (should erc--keep-place-indicator-overlay)
273 (should (local-variable-p 'window-configuration-change-hook))
274 (should window-configuration-change-hook)
275 (should erc-keep-place-mode)))
276 ;;
277 erc-insert-pre-hook
278 erc-modules)
279
280 (funcall assert-off)
281
282 (ert-info ("Value t")
283 (should (eq erc-keep-place-indicator-buffer-type t))
284 (erc-keep-place-indicator-mode +1)
285 (funcall assert-on)
286 (goto-char (point-min))
287 (should (search-forward "Enabling" nil t))
288 (should (memq 'keep-place erc-modules)))
289
290 (erc-keep-place-indicator-mode -1)
291 (funcall assert-off)
292
293 (ert-info ("Value `target'")
294 (let ((erc-keep-place-indicator-buffer-type 'target))
295 (erc-keep-place-indicator-mode +1)
296 (funcall assert-off)
297 (setq erc--target (erc--target-from-string "#chan"))
298 (erc-keep-place-indicator-mode +1)
299 (funcall assert-on)))
300
301 (erc-keep-place-indicator-mode -1)
302 (funcall assert-off)
303
304 (ert-info ("Value `server'")
305 (let ((erc-keep-place-indicator-buffer-type 'server))
306 (erc-keep-place-indicator-mode +1)
307 (funcall assert-off)
308 (setq erc--target nil)
309 (erc-keep-place-indicator-mode +1)
310 (funcall assert-on)))
311
312 ;; Populate buffer
313 (erc-display-message nil 'notice (current-buffer)
314 "This buffer is for text that is not saved")
315 (erc-display-message nil 'notice (current-buffer)
316 "and for lisp evaluation")
317 (should (search-forward "saved" nil t))
318 (erc-keep-place-move nil)
319 (goto-char erc-input-marker)
320
321 (ert-info ("Indicator survives reconnect")
322 (let ((erc--server-reconnecting (buffer-local-variables)))
323 (cl-letf (((symbol-function 'erc-server-connect) #'ignore))
324 (erc-open "localhost" 6667 "tester" "Tester" 'connect
325 nil nil nil nil nil "tester" nil)))
326 (funcall assert-on)
327 (should (= (point) erc-input-marker))
328 (goto-char (overlay-start erc--keep-place-indicator-overlay))
329 (should (looking-at (rx "*** This buffer is for text")))))
330
331 (when noninteractive
332 (kill-buffer))))
333
253;;; erc-goodies-tests.el ends here 334;;; erc-goodies-tests.el ends here