aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorlWarne <laurencewarne@gmail.com>2021-12-12 13:23:16 +0000
committerBozhidar Batsov <bozhidar@batsov.dev>2021-12-20 13:44:46 +0200
commit139cb02e20894cdf874d7a65659ef58d4b8f268b (patch)
treefa062bf49f83306dec76c4d4dc9f4c6e7a32d8d8 /test
parentfad389aecfe55e7f11d45bcdca6fa2f52f56ff16 (diff)
Fix tests
Diffstat (limited to 'test')
-rw-r--r--test/projectile-test.el41
1 files changed, 36 insertions, 5 deletions
diff --git a/test/projectile-test.el b/test/projectile-test.el
index 2624af2..77799f0 100644
--- a/test/projectile-test.el
+++ b/test/projectile-test.el
@@ -1163,8 +1163,23 @@ Just delegates OPERATION and ARGS for all operations except for`shell-command`'.
"spec/foo/foo.service.spec.js"
"spec/bar/bar.service.spec.js")
(:test-suffix ".spec" :test-dir "spec/" :src-dir "source/")
- (expect (projectile--find-matching-test "source/foo/foo.service.js") :to-equal '("spec/foo/foo.service.spec.js"))
- (expect (projectile--find-matching-file "spec/bar/bar.service.spec.js") :to-equal '("source/bar/bar.service.js")))))
+ (expect (projectile--find-matching-test
+ "project/source/foo/foo.service.js")
+ :to-equal '("spec/foo/foo.service.spec.js"))
+ (expect (projectile--find-matching-file
+ "project/spec/bar/bar.service.spec.js")
+ :to-equal '("source/bar/bar.service.js")))))
+
+ (it "finds matching test with dirs and inexistent test file"
+ (projectile-test-with-sandbox
+ (projectile-test-with-files-using-custom-project
+ ("project/src/main/scala/bar/package.scala"
+ "project/src/main/scala/foo/package.scala"
+ "project/src/test/scala/foo/packageSpec.scala")
+ (:test-suffix "Spec" :test-dir "test" :src-dir "main")
+ (expect (projectile--find-matching-test
+ "project/src/main/scala/bar/package.scala")
+ :to-equal '("src/test/scala/bar/packageSpec.scala")))))
(it "finds matching test or file based on the paths returned by :related-files-fn option"
(defun -my/related-files(file)
@@ -1721,7 +1736,8 @@ projectile-process-current-project-buffers-current to have similar behaviour"
((symbol-function 'file-exists-p) #'ignore)
((symbol-function 'projectile-expand-root) #'identity)
((symbol-function 'projectile-find-matching-test) (lambda (file) "dir/foo"))
- (projectile-create-missing-test-files nil))
+ (projectile-create-missing-test-files nil)
+ (projectile-project-type 'foo))
(expect (projectile-find-implementation-or-test "foo") :to-throw))))
(describe "projectile--impl-file-from-src-dir-fn"
@@ -1808,11 +1824,26 @@ projectile-process-current-project-buffers-current to have similar behaviour"
((symbol-function 'projectile-project-type) (lambda () 'foo))
(projectile-project-types mock-projectile-project-types))
(expect (projectile--impl-to-test-dir "/foo/src/Foo") :to-equal "/foo/test/")))
- (it "error signalled when test dir property is not a string"
+ (it "nil returned when test-dir property is not a string"
+ (cl-letf (((symbol-function 'projectile-project-root) (lambda () "bar"))
+ ((symbol-function 'projectile-project-type) (lambda () 'bar))
+ (projectile-project-types mock-projectile-project-types))
+ (expect (projectile--impl-to-test-dir "/bar/src/bar") :to-be nil))))
+
+(describe "projectile--test-to-impl-dir"
+ :var ((mock-projectile-project-types
+ '((foo test-dir "test" src-dir "src")
+ (bar test-dir "test" src-dir identity))))
+ (it "replaces occurrences of test-dir with src-dir"
+ (cl-letf (((symbol-function 'projectile-project-root) (lambda () "foo"))
+ ((symbol-function 'projectile-project-type) (lambda () 'foo))
+ (projectile-project-types mock-projectile-project-types))
+ (expect (projectile--test-to-impl-dir "/foo/test/Foo") :to-equal "/foo/src/")))
+ (it "nil returned when src-dir property is not a string"
(cl-letf (((symbol-function 'projectile-project-root) (lambda () "bar"))
((symbol-function 'projectile-project-type) (lambda () 'bar))
(projectile-project-types mock-projectile-project-types))
- (expect (projectile--impl-to-test-dir "/bar/src/bar") :to-throw))))
+ (expect (projectile--test-to-impl-dir "/bar/test/bar") :to-be nil))))
(describe "projectile-run-shell-command-in-root"
(describe "when called directly in elisp"