mirror of https://github.com/status-im/reagent.git
Merge branch 'test-browser-node-prod' into react-16-try2
This commit is contained in:
commit
601da7cc1d
|
@ -285,16 +285,21 @@
|
|||
|
||||
(defn component-path [c]
|
||||
;; Alternative branch for React 16
|
||||
(if-let [fiber (some-> c ($ :_reactInternalFiber))]
|
||||
;; Try both original name (for UMD foreign-lib) and manged name (property access, for Closure optimized React)
|
||||
(if-let [fiber (or (some-> c ($ :_reactInternalFiber))
|
||||
(some-> c (.-_reactInternalFiber)))]
|
||||
(fiber-component-path fiber)
|
||||
(let [elem (or (some-> (or (some-> c ($ :_reactInternalInstance))
|
||||
c)
|
||||
($ :_currentElement)))
|
||||
(let [instance (or (some-> c ($ :_reactInternalInstance))
|
||||
(some-> c (.-_reactInternalInstance))
|
||||
c)
|
||||
elem (or (some-> instance ($ :_currentElement))
|
||||
(some-> instance (.-_currentElement)))
|
||||
name (some-> elem
|
||||
($ :type)
|
||||
($ :displayName))
|
||||
path (some-> elem
|
||||
($ :_owner)
|
||||
owner (or (some-> elem ($ :_owner))
|
||||
(some-> elem (.-_owner)))
|
||||
path (some-> owner
|
||||
component-path
|
||||
(str " > "))
|
||||
res (str path name)]
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "Failure expected: https://github.com/facebook/react/issues/12368"
|
||||
echo
|
||||
|
||||
set -ex
|
||||
|
||||
lein do clean, doo chrome-headless prod-test-npm once || true
|
||||
test -f target/cljsbuild/prod-test-npm/main.js
|
||||
node_modules/.bin/gzip-size target/cljsbuild/prod-test-npm/main.js
|
|
@ -27,6 +27,9 @@
|
|||
|
||||
(def rflush r/flush)
|
||||
|
||||
(defn rstr [react-elem]
|
||||
(server/render-to-static-markup react-elem))
|
||||
|
||||
(deftest really-simple-test
|
||||
(when (and isClient
|
||||
(not (:really-simple-test @tests-done)))
|
||||
|
@ -347,15 +350,12 @@
|
|||
|
||||
(deftest test-static-markup
|
||||
(is (= "<div>foo</div>"
|
||||
(server/render-to-static-markup
|
||||
[:div "foo"])))
|
||||
(rstr [:div "foo"])))
|
||||
(is (= "<div class=\"bar\"><p>foo</p></div>"
|
||||
(server/render-to-static-markup
|
||||
[:div.bar [:p "foo"]])))
|
||||
(rstr [:div.bar [:p "foo"]])))
|
||||
(is (= "<div class=\"bar\"><p>foobar</p></div>"
|
||||
(server/render-to-static-markup
|
||||
[:div.bar {:dangerously-set-inner-HTML
|
||||
{:__html "<p>foobar</p>"}} ]))))
|
||||
(rstr [:div.bar {:dangerously-set-inner-HTML
|
||||
{:__html "<p>foobar</p>"}} ]))))
|
||||
|
||||
(deftest test-return-class
|
||||
(when isClient
|
||||
|
@ -417,9 +417,6 @@
|
|||
(is (= 1 @top-ran))
|
||||
(is (= 4 @ran)))))))
|
||||
|
||||
(defn rstr [react-elem]
|
||||
(server/render-to-static-markup react-elem))
|
||||
|
||||
(deftest test-create-element
|
||||
(let [ae r/as-element
|
||||
ce r/create-element]
|
||||
|
@ -1013,16 +1010,15 @@
|
|||
[:div "Something went wrong."]
|
||||
comp))}))
|
||||
comp1 (fn comp1 []
|
||||
($ nil :foo)
|
||||
[:div "foo"])]
|
||||
(throw (js/Error. "Test error")))]
|
||||
(debug/track-warnings
|
||||
(wrap-capture-window-error
|
||||
(wrap-capture-console-error
|
||||
#(with-mounted-component [error-boundary [comp1]]
|
||||
(fn [c div]
|
||||
(r/flush)
|
||||
(is (= "Cannot read property 'foo' of null" (.-message @error)))
|
||||
(is (found-in #"Something went wrong\." div)))))))))
|
||||
(is (= "Test error" (.-message @error)))
|
||||
(is (re-find #"Something went wrong\." (.-innerHTML div))))))))))
|
||||
|
||||
(deftest test-dom-node
|
||||
(let [node (atom nil)
|
||||
|
@ -1085,29 +1081,24 @@
|
|||
|
||||
(deftest style-property-names-are-camel-cased
|
||||
(is (re-find #"<div style=\"text-align:center(;?)\">foo</div>"
|
||||
(server/render-to-static-markup
|
||||
[:div {:style {:text-align "center"}} "foo"]))))
|
||||
(rstr [:div {:style {:text-align "center"}} "foo"]))))
|
||||
|
||||
(deftest custom-element-class-prop
|
||||
(is (re-find #"<custom-element class=\"foobar\">foo</custom-element>"
|
||||
(server/render-to-static-markup
|
||||
[:custom-element {:class "foobar"} "foo"])))
|
||||
(rstr [:custom-element {:class "foobar"} "foo"])))
|
||||
|
||||
(is (re-find #"<custom-element class=\"foobar\">foo</custom-element>"
|
||||
(server/render-to-static-markup
|
||||
[:custom-element.foobar "foo"]))))
|
||||
(rstr [:custom-element.foobar "foo"]))))
|
||||
|
||||
(deftest html-entities
|
||||
(testing "entity numbers can be unescaped always"
|
||||
(is (= "<i> </i>"
|
||||
(server/render-to-static-markup
|
||||
[:i (gstr/unescapeEntities " ")]))))
|
||||
(rstr [:i (gstr/unescapeEntities " ")]))))
|
||||
|
||||
(when r/is-client
|
||||
(testing "When DOM is available, all named entities can be unescaped"
|
||||
(is (= "<i> </i>"
|
||||
(server/render-to-static-markup
|
||||
[:i (gstr/unescapeEntities " ")]))))))
|
||||
(rstr [:i (gstr/unescapeEntities " ")]))))))
|
||||
|
||||
(defn context-wrapper []
|
||||
(r/create-class
|
||||
|
|
Loading…
Reference in New Issue