diff options
Diffstat (limited to 'tests/test-wttrin-location-history.el')
| -rw-r--r-- | tests/test-wttrin-location-history.el | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/tests/test-wttrin-location-history.el b/tests/test-wttrin-location-history.el index d23bdcd..4af8235 100644 --- a/tests/test-wttrin-location-history.el +++ b/tests/test-wttrin-location-history.el @@ -113,31 +113,37 @@ ;;; wttrin--completion-candidates (ert-deftest test-wttrin-location-history-normal-candidates-defaults-then-history () - "Candidates list defaults first, then history." + "Candidates list the sentinel, then defaults, then history." (test-wttrin-location-history-setup) (unwind-protect - (let ((wttrin-default-locations '("Honolulu, HI" "Berkeley, CA")) + (let ((wttrin-favorite-location nil) + (wttrin-default-locations '("Honolulu, HI" "Berkeley, CA")) (wttrin--location-history '("Tokyo" "Paris"))) - (should (equal '("Honolulu, HI" "Berkeley, CA" "Tokyo" "Paris") + (should (equal (list wttrin--geolocation-sentinel + "Honolulu, HI" "Berkeley, CA" "Tokyo" "Paris") (wttrin--completion-candidates)))) (test-wttrin-location-history-teardown))) (ert-deftest test-wttrin-location-history-normal-candidates-only-defaults () - "With empty history, candidates are just the defaults." + "With empty history, candidates are the sentinel then the defaults." (test-wttrin-location-history-setup) (unwind-protect - (let ((wttrin-default-locations '("Honolulu, HI")) + (let ((wttrin-favorite-location nil) + (wttrin-default-locations '("Honolulu, HI")) (wttrin--location-history nil)) - (should (equal '("Honolulu, HI") (wttrin--completion-candidates)))) + (should (equal (list wttrin--geolocation-sentinel "Honolulu, HI") + (wttrin--completion-candidates)))) (test-wttrin-location-history-teardown))) (ert-deftest test-wttrin-location-history-normal-candidates-only-history () - "With empty defaults, candidates are just the history." + "With empty defaults, candidates are the sentinel then the history." (test-wttrin-location-history-setup) (unwind-protect - (let ((wttrin-default-locations '()) + (let ((wttrin-favorite-location nil) + (wttrin-default-locations '()) (wttrin--location-history '("Tokyo"))) - (should (equal '("Tokyo") (wttrin--completion-candidates)))) + (should (equal (list wttrin--geolocation-sentinel "Tokyo") + (wttrin--completion-candidates)))) (test-wttrin-location-history-teardown))) ;;; wttrin-remove-location-history @@ -211,11 +217,13 @@ (should (memq 'wttrin--location-history savehist-additional-variables)))) (ert-deftest test-wttrin-location-history-boundary-savehist-register-idempotent () - "Registering when already present does not duplicate the entry." + "Registering an already-present variable does not duplicate it." (require 'savehist) - (let ((savehist-additional-variables '(wttrin--location-history))) + (require 'cl-lib) + (let ((savehist-additional-variables '(wttrin--location-history wttrin-favorite-location))) (wttrin--savehist-register) - (should (equal '(wttrin--location-history) savehist-additional-variables)))) + (should (= 1 (cl-count 'wttrin--location-history savehist-additional-variables))) + (should (= 1 (cl-count 'wttrin-favorite-location savehist-additional-variables))))) (ert-deftest test-wttrin-location-history-integration-savehist-register-on-save-hook () "The registration runs on `savehist-save-hook' so it survives a clobber." |
