   ([expected-component cursor m]
      (fn -sub-component-pred [component]
        (let [expected-name (component-name expected-component)
-             actual-name (component-name (:sub-component component))
-             actual-cursor @(:cursor component)
-             actual-m (:m component)]
+             {actual-sub-component :sub-component
+              actual-cursor :cursor
+              actual-m :m} (decode-sub-component component)
+             actual-name (component-name actual-sub-component)]
          (cond
-          (not= expected-component (:sub-component component))
+          (not= expected-component actual-sub-component)
           {:msg "sub-component does not match"
            :expected expected-name :actual actual-name}
 

(defn display-child
  ([component]
     (cond
      (not (nil? (.. component -props)))
      {
       :tag (tag-name component)
       :children (display-children (.. component -props -children))
       }
      (fn? component) {:sub-component (component-name component)}
      (string? component) {:text component}


(defn containing [& tests]
  (fn -containing-pred [component]
    (let [children (g-array/toArray (.. component -children))
          test-count (count tests)]
      (let [child-count (.-length children)]
        (if (not= test-count child-count)
          {:msg "Wrong number of child elements"
           :expected test-count :actual child-count
           :actual-children (display-children children)}
          (if-let [failures
                   (seq (filter (fn [result] (not= true result))
                                (map (fn [pred child] (pred child))
                                     tests children
                                     )))]
            failures
            true
            )
          )
        )
      )
    )
  )

(defn with-text [text]
  (fn -text-pred [component]
    (let [actual-text (.-textContent component)]
      (if (= text actual-text)
        true
        {:msg "Text does not match" :expected text :actual actual-text}
        )
      )
    )
  )
