From 92bcf84504a02294dcd435b6e2ae1aa82195dbf5 Mon Sep 17 00:00:00 2001 From: Juho Teperi Date: Fri, 28 Feb 2020 15:52:21 +0200 Subject: [PATCH] Use regex to check error component names Function names use $ instead of ., so allow both in regexes --- test/reagenttest/testreagent.cljs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/test/reagenttest/testreagent.cljs b/test/reagenttest/testreagent.cljs index 3717700..25a758d 100644 --- a/test/reagenttest/testreagent.cljs +++ b/test/reagenttest/testreagent.cljs @@ -586,7 +586,7 @@ #(with-mounted-component [c] (fn [c div]))))] (if (dev?) - (is (= "Warning: Every element in a seq should have a unique :key: ([:button {:on-click #object[Function]}] [:button {:on-click #object[Function]}] [:button {:on-click #object[Function]}])\n (in reagenttest.testreagent.key_tester)" + (is (re-find #"Warning: Every element in a seq should have a unique :key: \(\[:button \{:on-click #object\[Function\]\}\] \[:button \{:on-click #object\[Function\]\}\] \[:button \{:on-click #object\[Function\]\}\]\)\n \(in reagenttest.testreagent.key_tester\)" (first (:warn w))))))))) (deftest test-extended-syntax @@ -1041,8 +1041,6 @@ cmp) pkg "reagenttest.testreagent." stack1 (str "in " pkg "comp1") - re (fn [& s] - (re-pattern (apply str s))) rend (fn [x] (with-mounted-component x identity))] @@ -1051,19 +1049,19 @@ (wrap-capture-window-error (wrap-capture-console-error #(is (thrown-with-msg? - :default (re "Invalid tag: 'div.' \\(" stack1 "\\)") + :default #"Invalid tag: 'div.' \(in reagenttest.testreagent.comp1\)" (rend [comp2 [:div. "foo"]]))))))] - (is (= (str "Error rendering component (" stack1 ")") - (last (:error e))))) + (is (re-find #"Error rendering component \(in reagenttest.testreagent.comp1\)" + (last (:error e))))) (let [e (debug/track-warnings (wrap-capture-window-error (wrap-capture-console-error #(is (thrown-with-msg? - :default (re "Invalid tag: 'div.' \\(" stack1 "\\)") + :default #"Invalid tag: 'div.' \(in reagenttest.testreagent.comp1\)" (rend [comp1 [:div. "foo"]]))))))] - (is (= (str "Error rendering component (" stack1 ")") - (last (:error e))))) + (is (re-find #"Error rendering component \(in reagenttest.testreagent.comp1\)" + (last (:error e))))) (let [e (debug/track-warnings #(r/as-element [nat]))] (is (re-find #"Using native React classes directly"