Remove with-simulated-input
Some checks failed
/ Test on 28.2 (push) Failing after 3m14s
/ Test on 29.1 (push) Failing after 3m22s
/ Test on snapshot (push) Failing after 6m16s

This commit is contained in:
Maciej 2024-08-20 08:41:16 +03:00
parent fdf4c9da84
commit 5ac22ced29
Signed by: maciej
GPG key ID: 41D62D42D3B0D765
2 changed files with 32 additions and 21 deletions

View file

@ -1,11 +1,11 @@
;;; test-counsel-projectile.el --- Buttercup tests for counsel-projectile -*- lexical-binding: t; -*-
;;; Commentary:
;;; Code:
(require 'with-simulated-input)
(require 'counsel-projectile)
(require 'buttercup)
;; Example test!
(describe "counsel-projectile-switch-project with a mock"
(describe "counsel-projectile-switch-project"
(before-each
(spy-on 'ivy-read)
(spy-on 'projectile-project-root :and-return-value "/usr/fake-project")
@ -13,43 +13,55 @@
projectile-known-projects '("/usr/fake-project" "~/some-project")
counsel-projectile-switch-project-action 'counsel-projectile-switch-project-action))
(it "spies on ivy-read arguments"
(it "calls ivy-read"
(counsel-projectile-switch-project)
(expect 'projectile-project-root :to-have-been-called)
(expect 'ivy-read :to-have-been-called-with
(expect
'ivy-read
:to-have-been-called-with
"[fake-project] Switch to project: "
'("/usr/fake-project" "~/some-project")
:preselect "/usr/fake-project"
:action counsel-projectile-switch-project-action
:action 'counsel-projectile-switch-project-action
:require-match t
:sort nil
:caller 'counsel-projectile-switch-project)))
(describe "counsel-projectile-switch-project with the real ivy-read"
(describe "counsel-projectile-rg"
(before-each
(spy-on 'projectile-project-root :and-return-value "/usr/fake-project")
(setq
counsel-projectile-switch-project-action 'counsel-projectile-switch-project-action))
(spy-on 'ivy-read)
(spy-on 'projectile-project-root :and-return-value "/usr/fake-project"))
(it "signals error when project is unknown"
(it "calls ivy-read"
(counsel-projectile-rg)
(expect
(with-simulated-input "/usr/fake RET"
(condition-case err
(counsel-projectile-switch-project)
(file-missing
(error-message-string err))))
:to-equal "Setting current directory: No such file or directory, /usr/fake-project")))
'ivy-read
:to-have-been-called-with
"[fake-project] rg: "
'counsel-ag-function
:initial-input nil
:dynamic-collection t
:keymap '(keymap
(24 keymap (4 . counsel-cd))
(67108903 . swiper-avy)
(27 keymap (113 . counsel-git-grep-query-replace))
(12 . ivy-call-and-recenter))
:history 'counsel-git-grep-history
:action 'counsel-git-grep-action
:require-match t
:caller 'counsel-rg)))
(describe "counsel-projectile-find-file"
(before-each
(spy-on 'ivy-read)
(spy-on 'projectile-project-root :and-return-value user-emacs-directory))
(it "finds a file"
(it "calls ivy-read"
(counsel-projectile-find-file)
(expect 'ivy-read :to-have-been-called-with
"[29.1] Find file: " nil
(expect
'ivy-read
:to-have-been-called-with "[29.1] Find file: "
nil
:matcher 'counsel-projectile--find-file-matcher
:require-match t
:sort nil