Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add post-command-hook related tests #1093

Merged
merged 1 commit into from
Jan 19, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions tests/haskell-utils-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,30 @@ removed."
" TestTest Test test"
(haskell-utils-reduce-string " Test\r\nTest\n Test test"))))

(ert-deftest post-command-hooks ()
"Test commands related `haskell-utils-async-post-command-flag'.
Tests flag updates and `post-command-hook' cleanup."
(with-temp-switch-to-buffer
;; set some random value to flag to test that it will be reseted
(setq haskell-utils-async-post-command-flag "non nil")
(haskell-utils-async-watch-changes)
;; now flag should be empty
(should (null haskell-utils-async-post-command-flag))
;; execute some commands
(save-excursion (insert "Hello World!"))
(execute-kbd-macro (kbd "SPC"))
;; now flag should not be empty
(should (not (null haskell-utils-async-post-command-flag)))
;; check that hook was installed
(should (cl-member #'haskell-utils-async-update-post-command-flag
post-command-hook
:test #'equal))
;; check that flag was cleaned up
(haskell-utils-async-stop-watching-changes (current-buffer))
(should (null haskell-utils-async-post-command-flag))
;; check that hook was removed
(should (not (cl-member #'haskell-utils-async-update-post-command-flag
post-command-hook
:test #'equal)))))

;;; haskell-utils-tests.el ends here