mirror of
https://github.com/status-im/reagent.git
synced 2025-01-14 13:54:08 +00:00
Add a test for component-path
This commit is contained in:
parent
10562cfb9d
commit
3defd24c35
@ -289,8 +289,8 @@ the result can be compared with ="
|
||||
(util/partial-ifn. f args nil))
|
||||
|
||||
(defn component-path
|
||||
;;; Try to return the path of component c. Maybe useful for debugging
|
||||
;;; and error reporting, but may break with future versions of React.
|
||||
;;; Thus component-path may return nil.
|
||||
;; Try to return the path of component c as a string.
|
||||
;; Maybe useful for debugging and error reporting, but may break
|
||||
;; with future versions of React (and return nil).
|
||||
[c]
|
||||
(comp/component-path c))
|
||||
|
@ -540,3 +540,15 @@
|
||||
|
||||
(r/force-update (:c2 @comps) true)
|
||||
(is (= @v {:v1 3 :v2 3}))))))
|
||||
|
||||
(deftest test-component-path
|
||||
(let [a (atom nil)
|
||||
tc (r/create-class {:display-name "atestcomponent"
|
||||
:render (fn []
|
||||
(let [c (r/current-component)]
|
||||
(reset! a (r/component-path c))
|
||||
[:div]))})]
|
||||
(with-mounted-component [tc]
|
||||
(fn [c]
|
||||
(is (seq @a))
|
||||
(is (re-find #"atestcomponent" @a) "component-path should work")))))
|
||||
|
Loading…
x
Reference in New Issue
Block a user