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) #"\.")))))
|
||||
|
||||
(defn root-id [s]
|
||||
(keyword (first (string/split (name s) #"\."))))
|
||||
(keyword (string/join "." (butlast (string/split (name s) #"\.")))))
|
||||
|
||||
(defn parse [ctx ext]
|
||||
(reduce-kv (fn [acc hook-key data]
|
||||
|
|
|
@ -41,17 +41,19 @@
|
|||
(reader/validate {} {})))
|
||||
(is (= nil
|
||||
(reader/validate {} {'meta default-meta})))
|
||||
(is (= [{::errors/type ::errors/invalid-key ::errors/value 'hooks/test}]
|
||||
(reader/validate {} (extension {'hooks/test {:hook-id :a}}))))
|
||||
(is (= [{::errors/type ::errors/invalid-key ::errors/value 'hooks/test.id}]
|
||||
(reader/validate {} (extension {'hooks/test.id {:hook-id :a}}))))
|
||||
(is (= nil
|
||||
(reader/validate {:capacities {:hooks {:main {}}}}
|
||||
(extension {'hooks/main {:hook-id :a}}))))
|
||||
(is (= [{::errors/type ::errors/invalid-key ::errors/value 'hooks/unknown}]
|
||||
(extension {'hooks/main.id {:hook-id :a}}))))
|
||||
(is (= [{::errors/type ::errors/invalid-key ::errors/value 'hooks/unknown.id}]
|
||||
(reader/validate {:capacities {:hooks {:main {}}}}
|
||||
(extension {'hooks/main {:hook-id :a}
|
||||
'hooks/unknown {:hook-id :b}}))))
|
||||
(is (= [{::errors/type ::errors/invalid-key ::errors/value 'unknown/unknown}]
|
||||
(reader/validate {} (extension {'unknown/unknown {}})))))
|
||||
(extension {'hooks/main.id {:hook-id :a}
|
||||
'hooks/unknown.id {:hook-id :b}}))))
|
||||
(is (= [{::errors/type ::errors/invalid-key ::errors/value 'unknown/unknown.id}]
|
||||
(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-components {'text :text 'view :view})
|
||||
|
|
Loading…
Reference in New Issue