Fix up most lints in src/test

This commit is contained in:
Gabriel Horner
2022-01-07 18:12:23 -05:00
committed by Tienson Qin
parent 6987e40c2e
commit 97632c8c25
7 changed files with 126 additions and 135 deletions

View File

@@ -1,6 +1,5 @@
(ns frontend.db.query-dsl-test
(:require [cljs.test :refer [are async deftest testing use-fixtures]]
[datascript.core :as d]
[frontend.db :as db]
[frontend.db.config :refer [test-db] :as config]
[frontend.db.query-dsl :as dsl]

View File

@@ -1,6 +1,6 @@
(ns frontend.format.block-test
(:require [frontend.format.block :as block]
[cljs.test :refer [deftest is are testing use-fixtures run-tests]]))
[cljs.test :refer [deftest are]]))
(deftest test-extract-properties
(are [x y] (= (:properties (block/extract-properties x)) y)

View File

@@ -1,13 +1,11 @@
(ns frontend.handler.export-test
;; namespace local config for private function tests
{:clj-kondo/config {:linters {:private-call {:level :off}}}}
(:require [cljs.test :refer [async deftest is testing use-fixtures are]]
(:require [cljs.test :refer [async deftest use-fixtures are]]
[frontend.handler.export :as export]
[frontend.db.config :refer [test-db] :as config]
[frontend.db.config :as config]
[frontend.handler.repo :as repo-handler]
[frontend.fixtures :as fixtures]
[frontend.state :as state]
[clojure.string :as string]
[promesa.core :as p]))
(def test-files

View File

@@ -1,8 +1,5 @@
(ns frontend.modules.outliner.core-test
(:require [cljs-run-test :refer [run-test]]
[cljs.test :refer [deftest is run-tests use-fixtures] :as test]
[datascript.core :as d]
[frontend.core-test :as core-test]
(:require [cljs.test :refer [deftest is use-fixtures testing] :as test]
[frontend.fixtures :as fixtures]
[frontend.modules.outliner.core :as outliner-core]
[frontend.modules.outliner.datascript :as outliner-ds]
@@ -78,7 +75,7 @@
(prn (d/pull @(core-test/get-current-conn) '[*] [:block/uuid i])))))
(deftest test-insert-node-as-first-child
"
(testing "
Insert a node between 6 and 9.
[1 [[2 [[18] ;; add
[3 [[4]
@@ -92,19 +89,19 @@
[15]]]
[16 [[17]]]]]
"
(build-db-records node-tree)
(let [new-node (build-block 18 nil nil)
parent-node (build-block 2 1 1)]
(outliner-ds/auto-transact!
[state (outliner-ds/new-outliner-txs-state)] nil
(outliner-core/insert-node-as-first-child state new-node parent-node))
(let [children-of-2 (->> (build-block 2 1 1)
(tree/-get-children)
(mapv #(-> % :data :block/uuid)))]
(is (= [18 3 6 9] children-of-2)))))
(build-db-records node-tree)
(let [new-node (build-block 18 nil nil)
parent-node (build-block 2 1 1)]
(outliner-ds/auto-transact!
[state (outliner-ds/new-outliner-txs-state)] nil
(outliner-core/insert-node-as-first-child state new-node parent-node))
(let [children-of-2 (->> (build-block 2 1 1)
(tree/-get-children)
(mapv #(-> % :data :block/uuid)))]
(is (= [18 3 6 9] children-of-2))))))
(deftest test-insert-node-as-sibling
"
(testing "
Insert a node between 6 and 9.
[1 [[2 [[3 [[4]
[5]]]
@@ -117,20 +114,20 @@
[15]]]
[16 [[17]]]]]
"
(build-db-records node-tree)
(let [new-node (build-block 18 nil nil)
left-node (build-block 6 2 3)]
(outliner-ds/auto-transact!
[state (outliner-ds/new-outliner-txs-state)] nil
(outliner-core/insert-node-as-sibling state new-node left-node))
(let [children-of-2 (->> (build-block 2 1 1)
(tree/-get-children)
(mapv #(-> % :data :block/uuid)))]
(is (= [3 6 18 9] children-of-2)))))
(build-db-records node-tree)
(let [new-node (build-block 18 nil nil)
left-node (build-block 6 2 3)]
(outliner-ds/auto-transact!
[state (outliner-ds/new-outliner-txs-state)] nil
(outliner-core/insert-node-as-sibling state new-node left-node))
(let [children-of-2 (->> (build-block 2 1 1)
(tree/-get-children)
(mapv #(-> % :data :block/uuid)))]
(is (= [3 6 18 9] children-of-2))))))
(deftest test-delete-node
"
Inert a node between 6 and 9.
(testing "
Insert a node between 6 and 9.
[1 [[2 [[3 [[4]
[5]]]
[6 [[7 [[8]]]]] ;; delete 6
@@ -141,17 +138,17 @@
[15]]]
[16 [[17]]]]]
"
(build-db-records node-tree)
(let [node (build-block 6 2 3)]
(outliner-core/delete-node node true)
(let [children-of-2 (->> (build-block 2 1 1)
(tree/-get-children)
(mapv #(-> % :data :block/uuid)))]
(is (= [3 9] children-of-2)))))
(build-db-records node-tree)
(let [node (build-block 6 2 3)]
(outliner-core/delete-node node true)
(let [children-of-2 (->> (build-block 2 1 1)
(tree/-get-children)
(mapv #(-> % :data :block/uuid)))]
(is (= [3 9] children-of-2))))))
(deftest test-move-subtree-as-sibling
"
(testing "
Move 3 between 14 and 15.
[1 [[2 [[6 [[7 [[8]]]]]
[9 [[10]
@@ -163,21 +160,21 @@
[15]]]
[16 [[17]]]]]
"
(build-db-records node-tree)
(let [node (build-block 3 2 2)
target-node (build-block 14 12 13)]
(outliner-core/move-subtree node target-node true)
(let [old-parent's-children (->> (build-block 2 1 1)
(tree/-get-children)
(mapv #(-> % :data :block/uuid)))
new-parent's-children (->> (build-block 12 1 2)
(tree/-get-children)
(mapv #(-> % :data :block/uuid)))]
(is (= [6 9] old-parent's-children))
(is (= [13 14 3 15] new-parent's-children)))))
(build-db-records node-tree)
(let [node (build-block 3 2 2)
target-node (build-block 14 12 13)]
(outliner-core/move-subtree node target-node true)
(let [old-parent's-children (->> (build-block 2 1 1)
(tree/-get-children)
(mapv #(-> % :data :block/uuid)))
new-parent's-children (->> (build-block 12 1 2)
(tree/-get-children)
(mapv #(-> % :data :block/uuid)))]
(is (= [6 9] old-parent's-children))
(is (= [13 14 3 15] new-parent's-children)))))
(deftest test-move-subtree-as-first-child
"
(deftest test-move-subtree-as-first-child
(testing "
Move 3 as first child of 12.
[1 [[2 [[6 [[7 [[8]]]]]
@@ -190,22 +187,22 @@
[15]]]
[16 [[17]]]]]
"
(build-db-records node-tree)
(let [node (build-block 3 2 2)
target-node (build-block 12 1 2)]
(outliner-core/move-subtree node target-node false)
(let [old-parent's-children (->> (build-block 2 1 1)
(tree/-get-children)
(mapv #(-> % :data :block/uuid)))
new-parent's-children (->> (build-block 12 1 2)
(tree/-get-children)
(mapv #(-> % :data :block/uuid)))]
(is (= [6 9] old-parent's-children))
(is (= [3 13 14 15] new-parent's-children)))))
(build-db-records node-tree)
(let [node (build-block 3 2 2)
target-node (build-block 12 1 2)]
(outliner-core/move-subtree node target-node false)
(let [old-parent's-children (->> (build-block 2 1 1)
(tree/-get-children)
(mapv #(-> % :data :block/uuid)))
new-parent's-children (->> (build-block 12 1 2)
(tree/-get-children)
(mapv #(-> % :data :block/uuid)))]
(is (= [6 9] old-parent's-children))
(is (= [3 13 14 15] new-parent's-children)))))))
(deftest test-indent-nodes
"
(testing "
[1 [[2 [[3
[[4]
[5]
@@ -217,17 +214,17 @@
[15]]]
[16 [[17]]]]]
"
(build-db-records node-tree)
(let [nodes [(build-block 6 2 3)
(build-block 9 2 6)]]
(outliner-core/indent-outdent-nodes nodes true)
(let [children-of-3 (->> (build-block 3)
(tree/-get-children)
(mapv #(-> % :data :block/uuid)))]
(is (= [4 5 6 9] children-of-3)))))
(build-db-records node-tree)
(let [nodes [(build-block 6 2 3)
(build-block 9 2 6)]]
(outliner-core/indent-outdent-nodes nodes true)
(let [children-of-3 (->> (build-block 3)
(tree/-get-children)
(mapv #(-> % :data :block/uuid)))]
(is (= [4 5 6 9] children-of-3))))))
(deftest test-outdent-nodes
"
(testing "
[1 [[2 [[3]
[4] ;; outdent 6, 9
[5]
@@ -239,20 +236,20 @@
[15]]]
[16 [[17]]]]]
"
(build-db-records node-tree)
(let [nodes [(build-block 4 3 3)
(build-block 5 3 4)]]
(outliner-core/indent-outdent-nodes nodes false)
(let [children-of-2 (->> (build-block 2)
(tree/-get-children)
(mapv #(-> % :data :block/uuid)))]
(is (= [3 4 5 6 9] children-of-2)))))
(build-db-records node-tree)
(let [nodes [(build-block 4 3 3)
(build-block 5 3 4)]]
(outliner-core/indent-outdent-nodes nodes false)
(let [children-of-2 (->> (build-block 2)
(tree/-get-children)
(mapv #(-> % :data :block/uuid)))]
(is (= [3 4 5 6 9] children-of-2))))))
(comment
(run-test test-outdent-nodes))
(deftest test-delete-nodes
"
(testing "
[1 [[2 [[3 [[4]
[5]]]
;[6 [[7 [[8]]]]] delete 6, 9
@@ -264,21 +261,21 @@
[15]]]
[16 [[17]]]]]
"
(build-db-records node-tree)
(let [start-node (build-block 6 2 3)
end-node (build-block 11 9 10)
block-ids [7 8 9 10]]
(outliner-core/delete-nodes start-node end-node block-ids)
(let [children-of-2 (->> (build-block 2)
(tree/-get-children)
(mapv #(-> % :data :block/uuid)))]
(is (= [3] children-of-2)))))
(build-db-records node-tree)
(let [start-node (build-block 6 2 3)
end-node (build-block 11 9 10)
block-ids [7 8 9 10]]
(outliner-core/delete-nodes start-node end-node block-ids)
(let [children-of-2 (->> (build-block 2)
(tree/-get-children)
(mapv #(-> % :data :block/uuid)))]
(is (= [3] children-of-2))))))
(comment
(run-test test-delete-nodes))
(deftest test-move-node
"
(testing "
[1 [[2 [[3 [[4]
[5]]]
[9 [[10] ;; swap 6 and 9
@@ -289,19 +286,19 @@
[15]]]
[16 [[17]]]]]
"
(build-db-records node-tree)
(let [node (build-block 9 2 6)]
(outliner-core/move-nodes [node] true)
(let [children-of-2 (->> (build-block 2)
(tree/-get-children)
(mapv #(-> % :data :block/uuid)))]
(is (= [3 9 6] children-of-2)))))
(build-db-records node-tree)
(let [node (build-block 9 2 6)]
(outliner-core/move-nodes [node] true)
(let [children-of-2 (->> (build-block 2)
(tree/-get-children)
(mapv #(-> % :data :block/uuid)))]
(is (= [3 9 6] children-of-2))))))
(comment
(run-test test-move-node))
(deftest test-insert-nodes
"
(testing "
add [18 [19 20] 21] after 6
[1 [[2 [[3 [[4]
@@ -314,23 +311,23 @@
[15]]]
[16 [[17]]]]]
"
(build-db-records node-tree)
(let [new-nodes-tree [(build-block 18)
[(build-block 19)
(build-block 20)]
(build-block 21)]
target-node (build-block 6 2 3)]
(outliner-core/insert-nodes
new-nodes-tree target-node true)
(let [children-of-2 (->> (build-block 2)
(tree/-get-children)
(mapv #(-> % :data :block/uuid)))]
(is (= [3 6 18 21 9] children-of-2)))
(build-db-records node-tree)
(let [new-nodes-tree [(build-block 18)
[(build-block 19)
(build-block 20)]
(build-block 21)]
target-node (build-block 6 2 3)]
(outliner-core/insert-nodes
new-nodes-tree target-node true)
(let [children-of-2 (->> (build-block 2)
(tree/-get-children)
(mapv #(-> % :data :block/uuid)))]
(is (= [3 6 18 21 9] children-of-2)))
(let [children-of-18 (->> (build-block 18)
(tree/-get-children)
(mapv #(-> % :data :block/uuid)))]
(is (= [19 20] children-of-18)))))
(let [children-of-18 (->> (build-block 18)
(tree/-get-children)
(mapv #(-> % :data :block/uuid)))]
(is (= [19 20] children-of-18))))))
(comment
(run-test test-insert-nodes))

View File

@@ -1,6 +1,5 @@
(ns frontend.modules.outliner.ds-test
(:require [cljs-run-test :refer [run-test]]
[cljs.test :refer [deftest is use-fixtures] :as test]
(:require [cljs.test :refer [deftest is use-fixtures] :as test]
[frontend.fixtures :as fixtures]
[frontend.modules.outliner.datascript :as ds]))

View File

@@ -22,14 +22,14 @@
(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])]
(let [{: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)))))))))))
(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.
@@ -74,5 +74,3 @@
(let [result# ~@body]
(reset! react-components {})
result#))))

View File

@@ -2,7 +2,7 @@
;; 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 are testing use-fixtures run-tests]]
[cljs.test :refer [deftest is use-fixtures]]
[frontend.fixtures :as fixtures]))
(use-fixtures :each
@@ -62,4 +62,4 @@
(reset! b 4)
(is (= 10 @out-result)))))
(is (= 10 @out-result)))))