Added serialize and yet failing test

This commit is contained in:
Clemens 2023-08-02 09:34:06 +02:00
parent 0e00da5c9a
commit 3eff9a628e
2 changed files with 24 additions and 17 deletions

View file

@ -2,4 +2,13 @@
(:require [clojure.spec.alpha :as s] (:require [clojure.spec.alpha :as s]
[orchestra.core :refer [defn-spec]] [orchestra.core :refer [defn-spec]]
[org.domaindrivenarchitecture.activity-pub-poc.spec-helper :as sh] [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")))

View file

@ -2,22 +2,20 @@
(:require (:require
[clojure.test :refer [deftest is are testing run-tests]] [clojure.test :refer [deftest is are testing run-tests]]
[clojure.spec.alpha :as s] [clojure.spec.alpha :as s]
[clojure.string :as str]
[org.domaindrivenarchitecture.activity-pub-poc.core :as sut])) [org.domaindrivenarchitecture.activity-pub-poc.core :as sut]))
(deftest should-serailize (deftest should-serailize
(is (= "{ (is (= (str "{\"@context\": \"https://www.w3.org/ns/activitystreams\", "
\"@context\": \"https://www.w3.org/ns/activitystreams\", "\"summary\": \"Sally liked a note\", "
\"summary\": \"Sally liked a note\", "\"type\": \"Like\", "
\"type\": \"Like\", "\"actor\": {"
\"actor\": { "\"type\": \"Person\", "
\"type\": \"Person\", "\"name\": \"Sally\"}, "
\"name\": \"Sally\" "\"object\": \"http://example.org/notes/1\"}")
}, (sut/serialize
\"object\": \"http://example.org/notes/1\" {:summary "Sally liked a note",
}" :type "Like",
(sut/serialize :actor {:type "Person",
{:summary "Sally liked a note", :name "Sally"},
:type "Like", :object "http://example.org/notes/1"}))))
:actor {:type "Person",
:name "Sally"},
:object "http://example.org/notes/1"}))))