Skip to content

Commit

Permalink
fix(TRE-869): better props emptiness check (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
armed committed Oct 24, 2022
1 parent cecd6f0 commit 3e5dd5d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/k16/gx/beta/impl.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@

(defn push-down-props
[{{:keys [props-signals]} :normalize} {:gx/keys [props] :as node-def}]
(if (and (seq props) (seq props-signals))
(if (and props (seq props-signals))
(reduce-kv (fn [m k v]
(if (and (contains? props-signals k)
(not (:gx/props v)))
Expand Down
23 changes: 23 additions & 0 deletions test/k16/gx/beta/core_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -581,3 +581,26 @@
(is (= {:my-comp :stopped-val} (gx/values stopped)))
(is (= :some-instance (-> started :graph :my-comp :gx/instance)))
(is (= nil (-> stopped :graph :my-comp :gx/instance)))))))

(def ^:export empty-map-props-component
{:gx/start {:gx/processor (fn [{:keys [props]}]
{:gx/value props
:gx/instance :some-instance})
:gx/props-schema [:map]}
:gx/stop {:gx/processor (fn [{:keys [instance]}]
(when-not (= :some-instance instance)
(throw (ex-info "wrong instance" instance)))
:stopped-val)}})

(deftest empty-map-props-test
(let [graph {:my-comp {:gx/component 'k16.gx.beta.core-test/empty-map-props-component
:gx/props {}}}]
(test-async
(p/let [started (gx/signal {:graph graph} :gx/start)
stopped (gx/signal started :gx/stop)]
[started stopped])
(fn [[started stopped]]
(is (= {:my-comp nil} (gx/failures started)))
(is (= {:my-comp {}} (gx/values started)))
(is (= {} (-> stopped :graph :my-comp :gx/props)))))))

1 comment on commit 3e5dd5d

@vercel
Copy link

@vercel vercel bot commented on 3e5dd5d Oct 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

gx – ./

gx-kepler16.vercel.app
gx-git-master-kepler16.vercel.app
gx.kepler16.com

Please sign in to comment.