aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMatti Niemenmaa <matti.niemenmaa+github@iki.fi>2020-12-09 19:08:02 +0200
committerGitHub <noreply@github.com>2020-12-09 19:08:02 +0200
commitc7a1d201f7dbf600e7f27eaa21c608a0a85a1abf (patch)
tree35ba438a3c5a4da427ab6025a4b38d042c7e959a /test
parent0ff73ecf7f25f47382e2d28c8ab232c18609d515 (diff)
[#Fix 1617] Switch to right buffer in projectile-switch-project-by-name (#1621)
Diffstat (limited to 'test')
-rw-r--r--test/projectile-test.el33
1 files changed, 31 insertions, 2 deletions
diff --git a/test/projectile-test.el b/test/projectile-test.el
index 9de80cf..c85b75a 100644
--- a/test/projectile-test.el
+++ b/test/projectile-test.el
@@ -817,7 +817,7 @@ You'd normally combine this with `projectile-test-with-sandbox'."
(expect (projectile-switch-project) :to-throw))))
(describe "projectile-switch-project-by-name"
- (it "calls the switch project action with project-to-swtich's dir-locals loaded"
+ (it "calls the switch project action with project-to-switch's dir-locals loaded"
(defvar switch-project-foo)
(let ((foo 'bar)
(switch-project-foo)
@@ -833,7 +833,36 @@ You'd normally combine this with `projectile-test-with-sandbox'."
(projectile-add-known-project (file-name-as-directory (expand-file-name "project")))
(projectile-switch-project-by-name (file-name-as-directory (expand-file-name "project")))
- (expect switch-project-foo :to-be 'baz))))))
+ (expect switch-project-foo :to-be 'baz)))))
+
+ (it "runs hooks from the project root directory"
+ (defvar hook-dir)
+ (let ((projectile-switch-project-action
+ (lambda () (switch-to-buffer (find-file-noselect "file" t))))
+ (hook (lambda () (setq hook-dir default-directory))))
+ (add-hook 'projectile-after-switch-project-hook hook)
+ (projectile-test-with-sandbox
+ (projectile-test-with-files
+ ("project/"
+ "project/file")
+ (let ((project-dir (file-name-as-directory (expand-file-name "project"))))
+ (projectile-add-known-project project-dir)
+ (projectile-switch-project-by-name project-dir)
+ (remove-hook 'projectile-after-switch-project-hook hook)
+
+ (expect hook-dir :to-equal project-dir))))))
+
+ (it "ensures the buffer is switched immediately"
+ (let ((projectile-switch-project-action
+ (lambda () (switch-to-buffer (find-file-noselect "file" t)))))
+ (projectile-test-with-sandbox
+ (projectile-test-with-files
+ ("project/"
+ "project/file")
+ (projectile-add-known-project (file-name-as-directory (expand-file-name "project")))
+ (projectile-switch-project-by-name (file-name-as-directory (expand-file-name "project")))
+
+ (expect (current-buffer) :to-be (get-file-buffer "project/file")))))))
(describe "projectile-ignored-buffer-p"
(it "checks if buffer should be ignored"