From 72018520df67c11e1616b3461f1cc328e545d707 Mon Sep 17 00:00:00 2001 From: Juho Teperi Date: Mon, 18 Nov 2024 22:59:12 +0200 Subject: [PATCH] Use new test utils in more test cases --- demo/reagentdemo/intro.cljs | 2 ++ test/reagenttest/testreagent.cljs | 10 +--------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/demo/reagentdemo/intro.cljs b/demo/reagentdemo/intro.cljs index 6ed6e86b..9efe2262 100644 --- a/demo/reagentdemo/intro.cljs +++ b/demo/reagentdemo/intro.cljs @@ -56,6 +56,8 @@ [:p "Change it here: " [atom-input val]]]))) (defn timer-component [] + ;; FIXME: For some reason these timeouts trigger multiple + ;; renders and each render triggers a new timeout. (let [seconds-elapsed (r/atom 0)] (fn [] (js/setTimeout #(swap! seconds-elapsed inc) 1000) diff --git a/test/reagenttest/testreagent.cljs b/test/reagenttest/testreagent.cljs index d4a54d72..9949ada0 100644 --- a/test/reagenttest/testreagent.cljs +++ b/test/reagenttest/testreagent.cljs @@ -3,7 +3,6 @@ [clojure.test :as t :refer-macros [is deftest testing]] [goog.object :as gobj] [goog.string :as gstr] - [promesa.core :as p] [react :as react] [reagent.core :as r] [reagent.debug :as debug :refer [dev?]] @@ -726,7 +725,6 @@ (as-string [:div 1]))) (is (= [1 1 1] [@n1 @n2 @n3])))) -#_ (u/deftest ^:dom lifecycle (let [n1 (atom 0) t (atom 0) @@ -1046,7 +1044,6 @@ (.-componentStack ^js @info)))))))) #_{:clj-kondo/ignore [:deprecated-var]} -#_ (u/deftest ^:dom test-dom-node (let [node (atom nil) ref (atom nil) @@ -1072,6 +1069,7 @@ (is (= "

#object[reagent.ratom.RAtom {:val 1}]

" (as-string [:p (r/atom 1)])))) +;; FIXME: r/after-render won't work #_ (u/deftest ^:dom test-after-render (let [spy (atom 0) @@ -1164,7 +1162,6 @@ [:div "child," (gobj/get (.-context this) "foo")]))})) ;; Class component only -#_ (deftest ^:dom context-test (u/async (u/with-render [div [context-wrapper [context-child]]] @@ -1270,7 +1267,6 @@ (is (re-find #"Warning: Exception thrown while comparing argv's in shouldComponentUpdate:" (first (:warn @reagent.debug/warnings))))))))) -#_ (u/deftest ^:dom get-derived-state-from-props-test (let [prop (r/atom 0) ;; Usually one can use Cljs object as React state. However, @@ -1317,7 +1313,6 @@ (u/act (swap! prop inc)) (is (= "Error" (.-innerText div))))))) -#_ (u/deftest ^:dom get-snapshot-before-update-test (let [ref (react/createRef) prop (r/atom 0) @@ -1344,7 +1339,6 @@ (is (= {:height 20} @did-update)) (.removeChild js/document.body div))))) -#_ (u/deftest ^:dom issue-462-test (let [val (r/atom 0) render (atom 0) @@ -1389,7 +1383,6 @@ (finally (r/set-default-compiler! nil))))))) -#_ (deftest ^:dom functional-component-poc-state-hook (let [;; Probably not the best idea to keep ;; refernce to state hook update fn, but @@ -1435,7 +1428,6 @@ (u/act (@set-count! 17)) (is (= "Counts 6 17" (.-innerText div))))))) -#_ (u/deftest ^:dom test-input-el-ref (let [ref-1 (atom nil) ref-1-fn #(reset! ref-1 %)