From 3eff9a628eb857906a2301adeb657aa92f2d973e Mon Sep 17 00:00:00 2001 From: Clemens Date: Wed, 2 Aug 2023 09:34:06 +0200 Subject: [PATCH] Added serialize and yet failing test --- .../activity_pub_poc/core.cljc | 11 ++++++- .../activity_pub_poc/core_test.cljc | 30 +++++++++---------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/core.cljc b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/core.cljc index 354d2a2..5485fbc 100644 --- a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/core.cljc +++ b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/core.cljc @@ -2,4 +2,13 @@ (:require [clojure.spec.alpha :as s] [orchestra.core :refer [defn-spec]] [org.domaindrivenarchitecture.activity-pub-poc.spec-helper :as sh] - [org.domaindrivenarchitecture.activity-pub-poc.activitystreams2 :as as])) + [org.domaindrivenarchitecture.activity-pub-poc.activitystreams2 :as as] + [clojure.data.json :as json])) + +(defn serialize + [as-map] + (json/write-str + (assoc + as-map + (keyword "@context") + "https://www.w3.org/ns/activitystreams"))) \ No newline at end of file diff --git a/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/core_test.cljc b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/core_test.cljc index 7160d1b..69275b2 100644 --- a/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/core_test.cljc +++ b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/core_test.cljc @@ -2,22 +2,20 @@ (:require [clojure.test :refer [deftest is are testing run-tests]] [clojure.spec.alpha :as s] + [clojure.string :as str] [org.domaindrivenarchitecture.activity-pub-poc.core :as sut])) (deftest should-serailize - (is (= "{ - \"@context\": \"https://www.w3.org/ns/activitystreams\", - \"summary\": \"Sally liked a note\", - \"type\": \"Like\", - \"actor\": { - \"type\": \"Person\", - \"name\": \"Sally\" - }, - \"object\": \"http://example.org/notes/1\" -}" - (sut/serialize - {:summary "Sally liked a note", - :type "Like", - :actor {:type "Person", - :name "Sally"}, - :object "http://example.org/notes/1"})))) \ No newline at end of file + (is (= (str "{\"@context\": \"https://www.w3.org/ns/activitystreams\", " + "\"summary\": \"Sally liked a note\", " + "\"type\": \"Like\", " + "\"actor\": {" + "\"type\": \"Person\", " + "\"name\": \"Sally\"}, " + "\"object\": \"http://example.org/notes/1\"}") + (sut/serialize + {:summary "Sally liked a note", + :type "Like", + :actor {:type "Person", + :name "Sally"}, + :object "http://example.org/notes/1"})))) \ No newline at end of file