From cce1ddd0b77711b44ef4fde4014985d94281e59e Mon Sep 17 00:00:00 2001 From: lWarne Date: Sat, 24 Apr 2021 17:44:12 +0100 Subject: Add tests for added functions. Add tests for projectile-update-project-types which verify that it updates existing projects. Add tests for projectile--combine-lists which test its overriding logic and that it ignores nil values in secondary plists. --- test/projectile-test.el | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/test/projectile-test.el b/test/projectile-test.el index f4b6ea0..d5f6962 100644 --- a/test/projectile-test.el +++ b/test/projectile-test.el @@ -162,6 +162,20 @@ Just delegates OPERATION and ARGS for all operations except for`shell-command`'. (expect (projectile-expand-root "foo/bar") :to-equal "/path/to/project/foo/bar") (expect (projectile-expand-root "./foo/bar") :to-equal "/path/to/project/foo/bar"))) +(describe "projectile--combine-plists" + (it "Items in second plist override elements in first" + (expect (projectile--combine-plists + '(:foo "foo" :bar "bar") + '(:foo "foo" :bar "foo" :foobar "foobar")) + :to-equal + '(:foo "foo" :bar "foo" :foobar "foobar"))) + (it "Nil elements in second plist do not override elements in first" + (expect (projectile--combine-plists + '(:foo "foo" :bar "bar") + '(:foo "foo" :bar nil :foobar "foobar")) + :to-equal + '(:foo "foo" :bar "bar" :foobar "foobar")))) + (describe "projectile-register-project-type" (it "prepends new projects to projectile-project-types" (projectile-register-project-type 'foo '("Foo")) @@ -169,6 +183,42 @@ Just delegates OPERATION and ARGS for all operations except for`shell-command`'. (projectile-register-project-type 'bar '("Bar")) (expect (caar projectile-project-types) :to-equal 'bar))) +(describe "projectile-update-project-type" + :var ((mock-projectile-project-types + '((foo marker-files "marker-file" + project-file "project-file" + compilation-dir "compilation-dir" + configure-command "configure" + compile-command "compile" + test-command "test" + install-command "install" + package-command "package" + run-command "run")))) + (it "Updates existing project in projectile-project-types" + (let ((projectile-project-types mock-projectile-project-types)) + (projectile-update-project-type + 'foo + :marker-files "marker-file2" + :test-suffix "suffix") + (expect projectile-project-types :to-equal + '((foo marker-files "marker-file2" + project-file "project-file" + compilation-dir "compilation-dir" + configure-command "configure" + compile-command "compile" + test-command "test" + install-command "install" + package-command "package" + run-command "run" + test-suffix "suffix"))))) + (it "Error when attempt to update nonexistant project type" + (let ((projectile-project-types mock-projectile-project-types)) + (expect (projectile-update-project-type + 'bar + :marker-files "marker-file" + :test-suffix "suffix") + :to-throw)))) + (describe "projectile-project-type" (it "detects the type of Projectile's project" (expect (projectile-project-type) :to-equal 'emacs-eldev)) -- cgit v1.0