diff options
| author | lWarne <laurencewarne@gmail.com> | 2022-05-02 13:13:49 +0100 |
|---|---|---|
| committer | Bozhidar Batsov <bozhidar@batsov.dev> | 2022-05-22 10:41:15 +0300 |
| commit | 9de18b77b4ee7a1f5d27f15efd6216b62abfe20e (patch) | |
| tree | b1898bffa5422cecb46a3eb8125b7f894eb37b81 /test | |
| parent | b19725610e65fdc6d92341e62a5e8bb95371fc6c (diff) | |
Don't add duplicate commands to command history
Diffstat (limited to 'test')
| -rw-r--r-- | test/projectile-test.el | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/projectile-test.el b/test/projectile-test.el index e3d5a7f..55570bf 100644 --- a/test/projectile-test.el +++ b/test/projectile-test.el @@ -1988,6 +1988,27 @@ projectile-process-current-project-buffers-current to have similar behaviour" (funcall-interactively 'projectile-run-async-shell-command-in-root "cmd") (expect 'async-shell-command :to-have-been-called-with "cmd" nil nil)))) +(describe "projectile--run-project-cmd" + (it "command history is not duplicated" + (spy-on 'projectile-run-compilation) + (spy-on 'projectile-maybe-read-command :and-call-fake + (lambda (arg default-cmd prompt) default-cmd)) + ;; Stops projectile--run-project-cmd from creating a new directory for + ;; the compilation dir + (spy-on 'file-directory-p :and-return-value t) + (let ((command-map (make-hash-table :test 'equal)) + ;; history is based on the project root, so we set it to a random + ;; path to ensure there are no existing commands in history + (projectile-project-root "/a/random/path")) + (projectile--run-project-cmd "foo" command-map) + (projectile--run-project-cmd "foo" command-map) + (projectile--run-project-cmd "foo" command-map) + (projectile--run-project-cmd "bar" command-map) + (expect 'projectile-run-compilation :to-have-been-called-times 4) + (expect (ring-elements + (projectile--get-command-history projectile-project-root)) + :to-equal '("bar" "foo"))))) + ;; A bunch of tests that make sure Projectile commands handle ;; gracefully the case of being run outside of a project. (assert-friendly-error-when-no-project projectile-project-info) |
