Skip to content

Commit

Permalink
add-report return lookup refs for entities
Browse files Browse the repository at this point in the history
  • Loading branch information
lilactown committed Feb 21, 2021
1 parent 4fa008f commit c7c24d8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/autonormal/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
(rest entities)
(update-in db' (lookup-ref-of entity)
merge entity))
{:entities (set initial-entities)
{:entities (set (map lookup-ref-of initial-entities))
:db db'})))))


Expand All @@ -126,7 +126,7 @@
([db data]
(:db (add-report db data)))
([db data & more]
(apply add db data more)))
(reduce add (add db data) more)))


(defn db
Expand Down
14 changes: 13 additions & 1 deletion test/autonormal/core_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,20 @@

(t/deftest add-report
(t/is (= {:db {:person/id {0 {:person/id 0}}}
:entities #{{:person/id 0}}}
:entities #{[:person/id 0]}}
(a/add-report {} {:person/id 0})))
(t/is (= {:db {:person/id {0 {:person/id 0
:person/name "Gill"
:best-friend [:person/id 1]}
1 {:person/id 1
:person/name "Uma"}}
:me [:person/id 0]}
:entities #{[:person/id 0]
[:person/id 1]}}
(a/add-report {} {:me {:person/id 0
:person/name "Gill"
:best-friend {:person/id 1
:person/name "Uma"}}})))
#_(t/is (= {:db {:person/id {0 {:person/id 0 :person/name "Gill"}
1 {:person/id 1}}}
:entities #{{:person/id 0 :person/name "Gill"}
Expand Down

0 comments on commit c7c24d8

Please sign in to comment.