aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test-dev-fkeys--f6-current-file-tests-impl.el18
-rw-r--r--tests/test-dev-fkeys--f6-test-runner-cmd-for.el23
-rw-r--r--tests/test-prog-lsp--add-file-watch-ignored-extras.el29
3 files changed, 45 insertions, 25 deletions
diff --git a/tests/test-dev-fkeys--f6-current-file-tests-impl.el b/tests/test-dev-fkeys--f6-current-file-tests-impl.el
index 318a78db..1cf22230 100644
--- a/tests/test-dev-fkeys--f6-current-file-tests-impl.el
+++ b/tests/test-dev-fkeys--f6-current-file-tests-impl.el
@@ -105,13 +105,17 @@ just that file's tests run, not the whole module's prefix."
"/home/u/proj/modules/foo.el" nil)
:type 'user-error)))
-(ert-deftest test-dev-fkeys-f6-current-file-tests-impl-unsupported-language-errors ()
- "Error: a file with no language-specific runner signals a user-error
-naming the language."
- (cl-letf (((symbol-function 'compile) (lambda (_cmd) nil)))
- (should-error (cj/--f6-current-file-tests-impl
- "/home/u/proj/src/foo.test.ts" "/home/u/proj/")
- :type 'user-error)))
+(ert-deftest test-dev-fkeys-f6-current-file-tests-impl-typescript-runs-jest ()
+ "TypeScript now routes to the `npx --no-install jest|vitest <path>'
+runner instead of erroring as unsupported."
+ (let ((compile-called nil))
+ (cl-letf (((symbol-function 'compile)
+ (lambda (cmd) (setq compile-called cmd)))
+ ((symbol-function 'executable-find) (lambda (_) nil)))
+ (cj/--f6-current-file-tests-impl
+ "/home/u/proj/src/foo.test.ts" "/home/u/proj/")
+ (should (stringp compile-called))
+ (should (string-match-p "jest src/foo.test.ts" compile-called)))))
(ert-deftest test-dev-fkeys-f6-current-file-tests-impl-unknown-language-errors ()
"Error: an unknown extension signals a user-error rather than running
diff --git a/tests/test-dev-fkeys--f6-test-runner-cmd-for.el b/tests/test-dev-fkeys--f6-test-runner-cmd-for.el
index 36f97548..9a552612 100644
--- a/tests/test-dev-fkeys--f6-test-runner-cmd-for.el
+++ b/tests/test-dev-fkeys--f6-test-runner-cmd-for.el
@@ -118,10 +118,25 @@ would over-match. Pass just the basename — the Makefile re-prepends
;;; Error Cases
-(ert-deftest test-dev-fkeys-f6-cmd-for-typescript-returns-nil ()
- "Error: TypeScript is punted for v1 and returns nil."
- (should (null (cj/--f6-test-runner-cmd-for
- 'typescript t "src/foo.test.ts" "foo" "src"))))
+(ert-deftest test-dev-fkeys-f6-cmd-for-typescript-uses-jest-or-vitest ()
+ "Normal: TypeScript builds an `npx vitest|jest <path>' command.
+Picks vitest when on PATH, jest otherwise. Falls back to jest as the
+default runner so the command shape is always inspectable -- even if
+neither tool is present, the user gets a clear runner-not-found error
+rather than a silent nil that F6's outer wrapper interprets as
+\"language unsupported.\""
+ (cl-letf (((symbol-function 'executable-find)
+ (lambda (_) nil)))
+ (should (equal
+ (cj/--f6-test-runner-cmd-for
+ 'typescript t "src/foo.test.ts" "foo" "src")
+ "npx --no-install jest src/foo.test.ts")))
+ (cl-letf (((symbol-function 'executable-find)
+ (lambda (p) (when (equal p "vitest") "/usr/bin/vitest"))))
+ (should (equal
+ (cj/--f6-test-runner-cmd-for
+ 'typescript t "src/foo.test.ts" "foo" "src")
+ "npx --no-install vitest src/foo.test.ts"))))
(ert-deftest test-dev-fkeys-f6-cmd-for-javascript-returns-nil ()
"Error: JavaScript is punted for v1 and returns nil."
diff --git a/tests/test-prog-lsp--add-file-watch-ignored-extras.el b/tests/test-prog-lsp--add-file-watch-ignored-extras.el
index 142cd2ea..9b71cab8 100644
--- a/tests/test-prog-lsp--add-file-watch-ignored-extras.el
+++ b/tests/test-prog-lsp--add-file-watch-ignored-extras.el
@@ -87,23 +87,24 @@
(should-error (cj/lsp--add-file-watch-ignored-extras)
:type 'wrong-type-argument)))
-(ert-deftest test-prog-lsp--remove-eldoc-provider-removes-lsp-provider-locally ()
- "Normal: remove lsp-mode's Eldoc provider from the buffer-local hook."
- (with-temp-buffer
- (setq-local eldoc-documentation-functions
- '(lsp-eldoc-function eldoc-documentation-default))
- (cj/lsp--remove-eldoc-provider)
+(ert-deftest test-prog-lsp--remove-eldoc-provider-global-removes-from-default ()
+ "Normal: remove lsp-mode's Eldoc provider from the global hook value.
+The per-buffer removal that this replaced raced lsp-mode's own buffer-
+local hook population; removing globally before any LSP buffer attaches
+makes the absence stick for every subsequent lsp-managed buffer."
+ (let ((eldoc-documentation-functions
+ '(lsp-eldoc-function eldoc-documentation-default)))
+ (cj/lsp--remove-eldoc-provider-global)
(should-not (memq #'lsp-eldoc-function eldoc-documentation-functions))
(should (memq 'eldoc-documentation-default eldoc-documentation-functions))))
-(ert-deftest test-prog-lsp--remove-eldoc-provider-does-not-touch-default-value ()
- "Boundary: removing the LSP provider in one buffer leaves the default hook alone."
- (let ((eldoc-documentation-functions '(lsp-eldoc-function)))
- (with-temp-buffer
- (setq-local eldoc-documentation-functions '(lsp-eldoc-function))
- (cj/lsp--remove-eldoc-provider)
- (should-not (memq #'lsp-eldoc-function eldoc-documentation-functions)))
- (should (memq #'lsp-eldoc-function eldoc-documentation-functions))))
+(ert-deftest test-prog-lsp--remove-eldoc-provider-global-is-idempotent ()
+ "Boundary: re-running the removal after the provider is gone is a no-op."
+ (let ((eldoc-documentation-functions '(eldoc-documentation-default)))
+ (cj/lsp--remove-eldoc-provider-global)
+ (cj/lsp--remove-eldoc-provider-global)
+ (should (equal eldoc-documentation-functions
+ '(eldoc-documentation-default)))))
(ert-deftest test-prog-lsp--module-no-obsolete-lsp-eldoc-hook-reference ()
"Regression: prog-lsp should not reference obsolete `lsp-eldoc-hook'."