Browse Source

Remove unused test namespaces

frontend.react was only used in a test and never used elsewhere
Gabriel Horner 3 years ago
parent
commit
2c725ca5af

+ 0 - 3
src/test/frontend/db/conn.clj

@@ -1,3 +0,0 @@
-(ns frontend.db.conn)
-
-

+ 0 - 9
src/test/frontend/handler/block_test.cljs

@@ -1,9 +0,0 @@
-(ns frontend.handler.block-test)
-
-
-
-(comment
-  (defn clip-block [x]
-    (map #(select-keys % [:block/parent :block/left :block/pre-block? :block/uuid :block/level
-                          :db/id])
-      x)))

+ 0 - 67
src/test/frontend/react.cljc

@@ -1,67 +0,0 @@
-(ns frontend.react
-  "To facilitate testing, imitate the behavior of react.
-  Note: don't run component parallel"
-  #?(:cljs (:require-macros [frontend.react])))
-
-#_{:component-key {:result nil
-                   :watches []
-                   :root-info nil}}
-(def react-components (atom {}))
-(def ^:dynamic *with-key* nil)
-(def ^:dynamic *comp-key* nil)
-(def ^:dynamic *root-info* nil)
-
-(defn react
-  [react-ref]
-  (let [comp-key *comp-key*
-        component (get @react-components comp-key)]
-    (cond
-      (some? component)
-      (do
-        (when-not ((:watches component) react-ref)
-          (let [new-component (update component :watches conj react-ref)]
-            (swap! react-components assoc comp-key new-component)
-            (add-watch react-ref comp-key
-                       (fn [_key _atom old-state new-state]
-                         (when-not (= old-state new-state)
-                           (let [root-info (get-in @react-components [comp-key :root-info])
-                                 {:keys [f comp-key]} root-info]
-                             (binding [*with-key* comp-key
-                                       *root-info* root-info]
-                               (let [component (get @react-components comp-key)]
-                                 (reset! (:result component) (f))))))))))
-        @react-ref)
-
-      ;; Sometime react is not used in component by accident, return the val.
-      :else
-      @react-ref)))
-
-(defn set-comp-and-calc-result
-  [f]
-  (let [{result :result :as component} (get @react-components *comp-key*)]
-    (if component
-      (do (reset! result (f)) result)
-      (let [result (atom nil)]
-        (binding [*root-info* (if *root-info* *root-info* {:f f :comp-key *comp-key*})]
-          (let [component {:result result
-                           :watches #{}
-                           :root-info *root-info*}]
-            (swap! react-components assoc *comp-key* component))
-          (reset! result (f))
-          result)))))
-
-#?(:clj (defmacro defc
-          [sym args & body]
-          `(defn ~sym ~args
-             (let [f# (fn []
-                        (binding [*comp-key* *with-key*
-                                  ;; inner component should specify own *with-key*
-                                  *with-key* nil]
-                          ~@body))]
-               (binding [*comp-key* *with-key*]
-                 (set-comp-and-calc-result f#))))))
-
-#?(:clj (defmacro with-key
-          [key & body]
-          `(binding [*with-key* ~key]
-             ~@body)))

+ 0 - 64
src/test/frontend/react_test.cljs

@@ -1,64 +0,0 @@
-(ns frontend.react-test
-  ;; namespace local config for r/defc tests
-  {:clj-kondo/config {:linters {:inline-def {:level :off}}}}
-  (:require [frontend.react :as r]
-            [cljs.test :refer [deftest is use-fixtures]]
-            [frontend.test.fixtures :as fixtures]))
-
-(use-fixtures :each
-  fixtures/react-components)
-
-(deftest simple-react-test
-  (let [react-ref (atom 1)]
-
-    (r/defc simple-component
-      []
-      (+ 2 (r/react react-ref)))
-
-    (let [result (r/with-key 1 (simple-component))]
-
-      (is (= 3 @result))
-      (reset! react-ref 2)
-      (is (= 4 @result)))))
-
-(deftest nest-component-test
-  (let [a (atom 1)
-        b (atom 2)]
-
-    (r/defc inner
-      []
-
-      (let [r (r/react b)]
-        r))
-
-    (r/defc out
-      []
-      (let [out (r/react a)
-            inner-result (r/with-key "1" (inner))]
-        (+ out @inner-result)))
-
-    (let [out-result (r/with-key "2" (out))]
-      (is (= 3 @out-result))
-      (reset! b 4)
-      (is (= 5 @out-result)))))
-
-#_(deftest defc-params-test
-  (let [a (atom 1)
-        b (atom 2)]
-
-    (r/defc inner-1
-      [c]
-      (+ c (r/react b)))
-
-    (r/defc out-1
-      []
-      (let [out (r/react a)
-            inner-result (r/with-key 1 (inner-1 5))]
-        (+ out @inner-result)))
-
-    (let [out-result (r/with-key 2 (out-1))]
-      (is (= 8 @out-result))
-
-      (reset! b 4)
-
-      (is (= 10 @out-result)))))