Skip to content

Commit f314243

Browse files
committed
Merge pull request #1093 from geraldus/utils-coverage
Add post-command-hook related tests
2 parents 0b71c40 + 8453e6f commit f314243

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/haskell-utils-tests.el

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,30 @@ removed."
218218
" TestTest Test test"
219219
(haskell-utils-reduce-string " Test\r\nTest\n Test test"))))
220220

221+
(ert-deftest post-command-hooks ()
222+
"Test commands related `haskell-utils-async-post-command-flag'.
223+
Tests flag updates and `post-command-hook' cleanup."
224+
(with-temp-switch-to-buffer
225+
;; set some random value to flag to test that it will be reseted
226+
(setq haskell-utils-async-post-command-flag "non nil")
227+
(haskell-utils-async-watch-changes)
228+
;; now flag should be empty
229+
(should (null haskell-utils-async-post-command-flag))
230+
;; execute some commands
231+
(save-excursion (insert "Hello World!"))
232+
(execute-kbd-macro (kbd "SPC"))
233+
;; now flag should not be empty
234+
(should (not (null haskell-utils-async-post-command-flag)))
235+
;; check that hook was installed
236+
(should (cl-member #'haskell-utils-async-update-post-command-flag
237+
post-command-hook
238+
:test #'equal))
239+
;; check that flag was cleaned up
240+
(haskell-utils-async-stop-watching-changes (current-buffer))
241+
(should (null haskell-utils-async-post-command-flag))
242+
;; check that hook was removed
243+
(should (not (cl-member #'haskell-utils-async-update-post-command-flag
244+
post-command-hook
245+
:test #'equal)))))
246+
221247
;;; haskell-utils-tests.el ends here

0 commit comments

Comments
 (0)