[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/with-simulated-input 37047a2073 090/134: Add tests for loa
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/with-simulated-input 37047a2073 090/134: Add tests for loading and unloading |
Date: |
Mon, 10 Jan 2022 23:00:08 -0500 (EST) |
branch: elpa/with-simulated-input
commit 37047a2073793fca112aabbb27a03ed5fff5562d
Author: Ryan C. Thompson <rct@thompsonclan.org>
Commit: Ryan C. Thompson <rct@thompsonclan.org>
Add tests for loading and unloading
---
tests/test-unload.el | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 76 insertions(+)
diff --git a/tests/test-unload.el b/tests/test-unload.el
new file mode 100644
index 0000000000..fd3302944e
--- /dev/null
+++ b/tests/test-unload.el
@@ -0,0 +1,76 @@
+;;; -*- lexical-binding: t -*-
+
+(require 'buttercup)
+
+(require 'with-simulated-input)
+
+(defun has-advice (symbol advice)
+ (let ((advice-fun-to-find
+ (indirect-function advice))
+ (found nil))
+ (advice-mapc
+ (lambda (ad-fun ad-props)
+ (setq found
+ (or found
+ (equal (indirect-function ad-fun)
+ advice-fun-to-find))))
+ symbol)
+ found))
+
+(describe "The `with-simulated-input' library"
+
+ ;; Run each test with the library unloaded. Obviously this is not
+ ;; ideal since we are testing the unloading functionality, but
+ ;; there's not much else we can do. We reload the library after each
+ ;; test in order to restore the prior state.
+ (before-each
+ (when (featurep 'with-simulated-input)
+ (unload-feature 'with-simulated-input t)))
+ (after-each
+ (require 'with-simulated-input))
+
+ (it "should be able to load"
+ (expect (require 'with-simulated-input)
+ :not :to-throw))
+
+ (it "should apply the idle time advice when loading"
+ (require 'with-simulated-input)
+ (expect (has-advice #'current-idle-time
'current-idle-time@simulate-idle-time)
+ :to-be-truthy)
+ (spy-on 'current-idle-time@simulate-idle-time :and-call-through)
+ (current-idle-time)
+ (expect 'current-idle-time@simulate-idle-time
+ :to-have-been-called))
+
+ (it "should be able to unload"
+ ;; Load and unload 3 times, just to make sure there aren't errors
+ ;; on subsequent reloadings.
+ (expect (require 'with-simulated-input)
+ :not :to-throw)
+ (expect (featurep 'with-simulated-input))
+ (expect (unload-feature 'with-simulated-input t)
+ :not :to-throw)
+ (expect (not (featurep 'with-simulated-input)))
+ (expect (require 'with-simulated-input)
+ :not :to-throw)
+ (expect (featurep 'with-simulated-input))
+ (expect (unload-feature 'with-simulated-input t)
+ :not :to-throw)
+ (expect (not (featurep 'with-simulated-input)))
+ (expect (require 'with-simulated-input)
+ :not :to-throw)
+ (expect (featurep 'with-simulated-input))
+ (expect (unload-feature 'with-simulated-input t)
+ :not :to-throw)
+ (expect (not (featurep 'with-simulated-input))))
+
+ (it "should remove the idle time advice when unloading"
+ (expect (require 'with-simulated-input)
+ :not :to-throw)
+ (expect (has-advice #'current-idle-time
'current-idle-time@simulate-idle-time)
+ :to-be-truthy)
+ (expect (unload-feature 'with-simulated-input t)
+ :not :to-throw)
+ (expect (has-advice #'current-idle-time
'current-idle-time@simulate-idle-time)
+ :not :to-be-truthy)))
+;;; test-unload.el ends here
- [nongnu] elpa/with-simulated-input cc15ccfe5a 062/134: Switch CI to Github Actions, (continued)
- [nongnu] elpa/with-simulated-input cc15ccfe5a 062/134: Switch CI to Github Actions, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input af15d1a1f5 068/134: Remove interpolation test, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 6ac56316df 074/134: Revert version change, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 057946280f 070/134: Greeting test: don't use dynamic forms, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 214ca2c4b1 087/134: Improve test coverage for current-idle-time advice, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 1a610d6587 089/134: Reorganize test suite, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input c8389984e6 088/134: Update Eldev file, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 15581a4459 076/134: (symbol ...) KEYS are now function-call strings, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 38454eae74 086/134: Improve test coverage for wsi-get-unbound-key, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 82f8bada42 077/134: Fix tests, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 37047a2073 090/134: Add tests for loading and unloading,
ELPA Syncer <=
- [nongnu] elpa/with-simulated-input 2f40b160f5 096/134: Re-enable test for byte-compiled code, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 3525ed7dc5 095/134: Merge branch 'bleeding-edge' into rewrite-bleed, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 8f335ad321 108/134: Implement warnings for inputs that have no effect, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 8b4d44c3aa 104/134: Clean up wording in tests, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input ee4d2b75fd 133/134: Version 3.0, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 4e918757ae 111/134: Implement warnings for no-op KEYS inside a variable value, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input addb2a0711 122/134: Improve KEYS validation logic and error messages, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 0f43fe46d4 134/134: Add CI status badge to README, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 235a93f0fc 060/134: Add test for run-time evaluation of KEYS, ELPA Syncer, 2022/01/10
- [nongnu] elpa/with-simulated-input 5f0bc054b5 069/134: Better error propagation, ELPA Syncer, 2022/01/10