           "defaults as a to-one relation"
           (:input/cardinality f) => :one
           "is marked as a subform"
-          (true? (:input/is-form? f)) => true
+          f =fn=> f/is-subform?
           "has the correct type"
           (:input/type f) => ::f/subform
           "tracks the class of the subform UI"

    "gives back pairs of [prop-path class] on a singly-nested form"
    (f/subforms* Level2Form) => [[[:leaf1] LeafForm] [[:leaf2] LeafForm] [[:leaf3] LeafForm]]
    "gives back pairs of [prop-path class] on a nested form"
    (f/subforms* Level3Form) => [[[:level2] Level2Form] [[:level2 :leaf1] LeafForm] [[:level2 :leaf2] LeafForm] [[:level2 :leaf3] LeafForm]]
    "supports to-many sub-forms"
    (f/subforms* ToManyForm) => [[[:leaves] LeafForm]]))

(def nested-form-db (om/tree->db [{:root (om/get-query Level3Form)}] {:root (uc/initial-state Level3Form {})} true))
(def tomany-form-db (om/tree->db [{:root (om/get-query ToManyForm)}] {:root (uc/initial-state ToManyForm {})} true))

(specification "to-idents"
  (assertions
    "finds a sequence of idents by walking the graph (to-one)"
    (f/to-idents person-db (get-in person-db [:people/by-id 1]) [:person/number]) => [[:phone/by-id 1]]
    "finds a sequence of idents by walking the graph (to-many)"
    (f/to-idents tomany-form-db (get-in tomany-form-db [:tomform 99]) [:leaves]) => [[:leaf 3] [:leaf 4]]))

(specification "get-forms"
  (assertions
    "Obtains a list of nested forms and idents that are BOTH declared as subforms AND are present (others are skipped)."
    (f/get-forms nested-form-db Level3Form [:level3 1]) => [{:ident [:level3 1] :class Level3Form :form {:id 1 :level3 true :other-root [:other 100] :level2 [:level2 2]}}
                                                            {:ident [:level2 2] :class Level2Form :form {:id 2 :value 1 :level2 true :leaf1 [:leaf 5] :leaf2 [:leaf 6]}}
                                                            {:ident [:leaf 5] :class LeafForm :form {:id 5 :value 1 :leaf true}}
                                                            {:ident [:leaf 6] :class LeafForm :form {:id 6 :value 1 :leaf true}}]
    "Can pull to-many relations of sub-forms"
    (f/get-forms tomany-form-db ToManyForm [:tomform 99]) => [{:ident [:tomform 99]
                                                               :class ToManyForm
                                                               :form  {:id 99 :to-many true :value 1 :leaves [[:leaf 3] [:leaf 4]]}}
                                                              {:ident [:leaf 3]
                                                               :class LeafForm
                                                               :form  {:id 3 :value 1 :leaf true}}
                                                              {:ident [:leaf 4]
                                                               :class LeafForm
                                                               :form  {:id 4 :value 1 :leaf true}}]))

(specification "update-forms"
  (let [state (f/init-form nested-form-db Level3Form [:level3 1])

(let [app-state (-> person-db
                  (f/init-form Phone [:phone/by-id 1])
                  (f/init-form Phone [:phone/by-id 2])
                  (f/init-form Person [:people/by-id 7])
                  (f/init-form Person [:people/by-id 3])
                  (f/init-form PolyPerson [:people/by-id 4])
                  (f/init-form PolyPerson [:people/by-id 5])
                  (f/init-form PolyPerson [:people/by-id 6]))
      basic-person (get-in app-state [:people/by-id 3])
      one-number-person (get-in app-state [:people/by-id 7])
      no-number-person (get-in app-state [:people/by-id 5])
      many-number-person (get-in app-state [:people/by-id 4])
      one-many-number-person (get-in app-state [:people/by-id 6])
