From 8aea2c5326bb94eb1ec3e9d301c63b0ac0a15769 Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Fri, 28 Jul 2023 17:06:24 +0200 Subject: [PATCH] refactore out more spec-herlper fcts --- .../activity_pub_poc/spec_helper.cljc | 8 +++++++- ...tystreams2_test.clj => activitystreams2_test.cljc} | 4 ---- .../activity_pub_poc/spec_helper_test.cljc | 11 +++++++++++ 3 files changed, 18 insertions(+), 5 deletions(-) rename src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/{activitystreams2_test.clj => activitystreams2_test.cljc} (90%) create mode 100644 src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/spec_helper_test.cljc diff --git a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/spec_helper.cljc b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/spec_helper.cljc index cfebc7e..cada86f 100644 --- a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/spec_helper.cljc +++ b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/spec_helper.cljc @@ -11,4 +11,10 @@ (s/and (s/or :no-map #(not (map? %)) - :map spec))) \ No newline at end of file + :map spec))) + +(defn-spec + is-functional-property? boolean? + "Checks whether spec is a FunctionalProperty." + [spec s/spec?] + (some #(clojure.string/includes? % "FunctionalProperty") (s/describe spec))) \ No newline at end of file diff --git a/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.clj b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.cljc similarity index 90% rename from src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.clj rename to src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.cljc index 6d98ee3..136504f 100644 --- a/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.clj +++ b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.cljc @@ -5,10 +5,6 @@ [clojure.spec.alpha :as s] [org.domaindrivenarchitecture.activity-pub-poc.activitystreams2 :as sut])) -(deftest shoult-test-spec-for-having-functional-property - (is (sut/is-functional-property? ::sut/id)) - (is (not (sut/is-functional-property? ::sut/Like)))) - (deftest id-test (is (s/valid? ::sut/id "https://social.bla/alyssa/status/RANDOMHASH")) (is (not (s/valid? ::sut/id nil))) diff --git a/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/spec_helper_test.cljc b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/spec_helper_test.cljc new file mode 100644 index 0000000..cb7f08a --- /dev/null +++ b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/spec_helper_test.cljc @@ -0,0 +1,11 @@ +(ns org.domaindrivenarchitecture.activity-pub-poc.spec-helper-test + (:require + [clojure.test :refer [deftest is are testing run-tests]] + [clojure.spec.test.alpha :as st] + [clojure.spec.alpha :as s] + [org.domaindrivenarchitecture.activity-pub-poc.activitystreams2 :as as2] + [org.domaindrivenarchitecture.activity-pub-poc.spec-helper :as sut])) + +(deftest shoult-test-spec-for-having-functional-property + (is (sut/is-functional-property? ::as2/id)) + (is (not (sut/is-functional-property? ::as2/Like)))) \ No newline at end of file