Hooks can have dotted namespaces

This commit is contained in:
Julien Eluard 2018-11-14 10:22:01 +01:00
parent c6ba642159
commit 71db93d028
No known key found for this signature in database
GPG Key ID: 6FD7DB5437FCBEF6
2 changed files with 11 additions and 9 deletions

View File

@ -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]

View File

@ -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})