mirror of https://github.com/status-im/pluto.git
Hooks can have dotted namespaces
This commit is contained in:
parent
c6ba642159
commit
71db93d028
|
@ -18,7 +18,7 @@
|
||||||
(keyword (string/join "." (rest (string/split (name s) #"\.")))))
|
(keyword (string/join "." (rest (string/split (name s) #"\.")))))
|
||||||
|
|
||||||
(defn root-id [s]
|
(defn root-id [s]
|
||||||
(keyword (first (string/split (name s) #"\."))))
|
(keyword (string/join "." (butlast (string/split (name s) #"\.")))))
|
||||||
|
|
||||||
(defn parse [ctx ext]
|
(defn parse [ctx ext]
|
||||||
(reduce-kv (fn [acc hook-key data]
|
(reduce-kv (fn [acc hook-key data]
|
||||||
|
|
|
@ -41,17 +41,19 @@
|
||||||
(reader/validate {} {})))
|
(reader/validate {} {})))
|
||||||
(is (= nil
|
(is (= nil
|
||||||
(reader/validate {} {'meta default-meta})))
|
(reader/validate {} {'meta default-meta})))
|
||||||
(is (= [{::errors/type ::errors/invalid-key ::errors/value 'hooks/test}]
|
(is (= [{::errors/type ::errors/invalid-key ::errors/value 'hooks/test.id}]
|
||||||
(reader/validate {} (extension {'hooks/test {:hook-id :a}}))))
|
(reader/validate {} (extension {'hooks/test.id {:hook-id :a}}))))
|
||||||
(is (= nil
|
(is (= nil
|
||||||
(reader/validate {:capacities {:hooks {:main {}}}}
|
(reader/validate {:capacities {:hooks {:main {}}}}
|
||||||
(extension {'hooks/main {:hook-id :a}}))))
|
(extension {'hooks/main.id {:hook-id :a}}))))
|
||||||
(is (= [{::errors/type ::errors/invalid-key ::errors/value 'hooks/unknown}]
|
(is (= [{::errors/type ::errors/invalid-key ::errors/value 'hooks/unknown.id}]
|
||||||
(reader/validate {:capacities {:hooks {:main {}}}}
|
(reader/validate {:capacities {:hooks {:main {}}}}
|
||||||
(extension {'hooks/main {:hook-id :a}
|
(extension {'hooks/main.id {:hook-id :a}
|
||||||
'hooks/unknown {:hook-id :b}}))))
|
'hooks/unknown.id {:hook-id :b}}))))
|
||||||
(is (= [{::errors/type ::errors/invalid-key ::errors/value 'unknown/unknown}]
|
(is (= [{::errors/type ::errors/invalid-key ::errors/value 'unknown/unknown.id}]
|
||||||
(reader/validate {} (extension {'unknown/unknown {}})))))
|
(reader/validate {} (extension {'unknown/unknown.id {}}))))
|
||||||
|
(is (= nil
|
||||||
|
(reader/validate {:capacities {:hooks {:some.ns {}}}} (extension {'hooks/some.ns.id {}})))))
|
||||||
|
|
||||||
(def default-hooks {:main {:properties {:view :view}}})
|
(def default-hooks {:main {:properties {:view :view}}})
|
||||||
(def default-components {'text :text 'view :view})
|
(def default-components {'text :text 'view :view})
|
||||||
|
|
Loading…
Reference in New Issue