Skip to content

Commit

Permalink
Cleanup unused test utils
Browse files Browse the repository at this point in the history
  • Loading branch information
Deraen committed Nov 23, 2024
1 parent 421bb35 commit 761d4b8
Showing 1 changed file with 1 addition and 56 deletions.
57 changes: 1 addition & 56 deletions test/reagenttest/utils.cljs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
(ns reagenttest.utils
(:require-macros reagenttest.utils)
(:require [promesa.core :as p]
[react :as react]
[reagent.core :as r]
[reagent.debug :as debug :refer [dev?]]
[reagent.debug :as debug]
[reagent.dom :as rdom]
[reagent.dom.server :as server]
[reagent.impl.template :as tmpl]))
Expand Down Expand Up @@ -36,39 +35,6 @@
(defn as-string [comp]
(server/render-to-static-markup comp *test-compiler*))

(defn with-mounted-component
([comp f]
(with-mounted-component comp *test-compiler* f))
([comp compiler f]
(let [div (.createElement js/document "div")]
(try
(let [c (if compiler
(rdom/render comp div compiler)
(rdom/render comp div))]
(f c div))
(finally
(rdom/unmount-component-at-node div)
(r/flush))))))

(defn with-mounted-component-async
[comp done compiler f]
(let [div (.createElement js/document "div")
c (if compiler
(rdom/render comp div compiler)
(rdom/render comp div))]
(f c div (fn []
(rdom/unmount-component-at-node div)
(r/flush)
(done)))))

(defn run-fns-after-render [& fs]
((reduce (fn [cb f]
(fn []
(r/after-render (fn []
(f)
(cb)))))
(reverse fs))))

;; For testing logged errors and warnings

(defn log-error [& f]
Expand All @@ -85,27 +51,6 @@
(finally
(set! js/console.error org))))))

(defn wrap-capture-window-error [f]
(if (exists? js/window)
(fn []
(let [org js/console.onerror]
(set! js/window.onerror (fn [e]
(log-error e)
true))
(try
(f)
(finally
(set! js/window.onerror org)))))
(fn []
(let [process (js/require "process")
l (fn [e]
(log-error e))]
(.on process "uncaughtException" l)
(try
(f)
(finally
(.removeListener process "uncaughtException" l)))))))

;; Promise versions

(defn wrap-capture-console-error-promise [f]
Expand Down

0 comments on commit 761d4b8

Please sign in to comment.