diff options
Diffstat (limited to 'tests/test-dev-fkeys--f6-test-runner.el')
| -rw-r--r-- | tests/test-dev-fkeys--f6-test-runner.el | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/tests/test-dev-fkeys--f6-test-runner.el b/tests/test-dev-fkeys--f6-test-runner.el new file mode 100644 index 000000000..23129539b --- /dev/null +++ b/tests/test-dev-fkeys--f6-test-runner.el @@ -0,0 +1,76 @@ +;;; test-dev-fkeys--f6-test-runner.el --- Smoke tests for cj/f6-test-runner -*- lexical-binding: t -*- + +;;; Commentary: +;; Smoke tests for the F6 top-level menu. The wrapper: +;; +;; 1. Prompts via completing-read with two candidates. +;; 2. \"All tests\" invokes `projectile-test-project'. +;; 3. \"Current file's tests\" invokes `cj/--f6-current-file-tests-impl' +;; with the buffer's file and the project root. +;; +;; The orchestrator and helpers are tested in their own files; this file +;; just confirms the wiring. + +;;; Code: + +(require 'ert) +(require 'cl-lib) +(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory)) +(require 'dev-fkeys) + +;;; Normal Cases + +(ert-deftest test-dev-fkeys-f6-test-runner-prompts-with-completing-read () + "Normal: F6 prompts with the two-entry candidate list." + (let (seen-candidates) + (cl-letf (((symbol-function 'completing-read) + (lambda (_prompt collection &rest _) + (setq seen-candidates collection) + (car collection))) + ((symbol-function 'projectile-test-project) + (lambda (_arg) nil)) + ((symbol-function 'cj/--f4-project-root) (lambda () "/p/")) + ((symbol-function 'cj/--f6-current-file-tests-impl) + (lambda (_f _r) nil))) + (cj/f6-test-runner) + (should (member "All tests" seen-candidates)) + (should (member "Current file's tests" seen-candidates))))) + +(ert-deftest test-dev-fkeys-f6-test-runner-all-tests-routes-to-projectile () + "Normal: choosing 'All tests' invokes projectile-test-project." + (let ((calls 0)) + (cl-letf (((symbol-function 'completing-read) + (lambda (&rest _) "All tests")) + ((symbol-function 'projectile-test-project) + (lambda (_arg) (cl-incf calls))) + ((symbol-function 'cj/--f4-project-root) (lambda () "/p/")) + ((symbol-function 'cj/--f6-current-file-tests-impl) + (lambda (_f _r) nil))) + (cj/f6-test-runner) + (should (= calls 1))))) + +(ert-deftest test-dev-fkeys-f6-test-runner-current-file-routes-to-impl () + "Normal: choosing 'Current file's tests' invokes the orchestrator with +the buffer file and projectile root. + +Components integrated: +- `cj/f6-test-runner' (unit under test) +- `completing-read' (MOCKED — picks the second label) +- `cj/--f4-project-root' (MOCKED — fixed root) +- `cj/--f6-current-file-tests-impl' (MOCKED — captures args) +- `buffer-file-name' (MOCKED via cl-letf)" + (let (seen-file seen-root) + (cl-letf (((symbol-function 'completing-read) + (lambda (&rest _) "Current file's tests")) + ((symbol-function 'projectile-test-project) (lambda (_arg) nil)) + ((symbol-function 'cj/--f4-project-root) (lambda () "/p/")) + ((symbol-function 'buffer-file-name) (lambda () "/p/foo.el")) + ((symbol-function 'cj/--f6-current-file-tests-impl) + (lambda (file root) + (setq seen-file file seen-root root)))) + (cj/f6-test-runner) + (should (string= seen-file "/p/foo.el")) + (should (string= seen-root "/p/"))))) + +(provide 'test-dev-fkeys--f6-test-runner) +;;; test-dev-fkeys--f6-test-runner.el ends here |
