From 8453e6ff459703209f189a362f5a879b1d28b291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arthur=20Fayzrakhmanov=20=28=D0=90=D1=80=D1=82=D1=83=D1=80?= =?UTF-8?q?=20=D0=A4=D0=B0=D0=B9=D0=B7=D1=80=D0=B0=D1=85=D0=BC=D0=B0=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=29?= Date: Mon, 18 Jan 2016 03:54:48 +0500 Subject: [PATCH] Add post-command-hook related tests --- tests/haskell-utils-tests.el | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/haskell-utils-tests.el b/tests/haskell-utils-tests.el index 1c57cf126..68cac7e24 100644 --- a/tests/haskell-utils-tests.el +++ b/tests/haskell-utils-tests.el @@ -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