From 24f2f3b677cbdd32eb40c409535cb00a6300739f Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 30 Apr 2020 10:08:36 +0200 Subject: [PATCH] :tada: Add tests build. --- frontend/deps.edn | 2 +- frontend/shadow-cljs.edn | 10 +- frontend/test/uxbox/tests/main.cljs | 22 --- .../tests/test_main_data_shapes_impl.cljs | 126 ------------------ .../tests => tests/uxbox}/test_util_geom.cljs | 4 +- 5 files changed, 11 insertions(+), 153 deletions(-) delete mode 100644 frontend/test/uxbox/tests/main.cljs delete mode 100644 frontend/test/uxbox/tests/test_main_data_shapes_impl.cljs rename frontend/{test/uxbox/tests => tests/uxbox}/test_util_geom.cljs (94%) diff --git a/frontend/deps.edn b/frontend/deps.edn index eee198a35..75ed4f72f 100644 --- a/frontend/deps.edn +++ b/frontend/deps.edn @@ -21,7 +21,7 @@ } :aliases {:dev - {:extra-paths ["test" "dev"] + {:extra-paths ["tests" "dev"] :extra-deps {com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"} com.bhauman/rebel-readline {:mvn/version "0.1.4"} diff --git a/frontend/shadow-cljs.edn b/frontend/shadow-cljs.edn index 7113cf14b..604086dcc 100644 --- a/frontend/shadow-cljs.edn +++ b/frontend/shadow-cljs.edn @@ -27,4 +27,12 @@ {:fn-invoke-direct true :source-map true :anon-fn-naming-policy :off - :source-map-detail-level :all}}}}} + :source-map-detail-level :all}}} + + :tests + {:target :node-test + :output-to "target/tests.js" + :ns-regexp "^uxbox.test-" + :autorun true}}} + + diff --git a/frontend/test/uxbox/tests/main.cljs b/frontend/test/uxbox/tests/main.cljs deleted file mode 100644 index 3619ba217..000000000 --- a/frontend/test/uxbox/tests/main.cljs +++ /dev/null @@ -1,22 +0,0 @@ -(ns uxbox.tests.main - (:require [cljs.test :as test] - [uxbox.tests.test-util-geom] - [uxbox.tests.test-main-data-shapes-impl])) - -(enable-console-print!) - -(defn main - [] - (test/run-tests - (test/empty-env) - 'uxbox.tests.test-util-geom - 'uxbox.tests.test-main-data-shapes-impl - )) - -(defmethod test/report [:cljs.test/default :end-run-tests] - [m] - (if (test/successful? m) - (set! (.-exitCode js/process) 0) - (set! (.-exitCode js/process) 1))) - -(set! *main-cli-fn* main) diff --git a/frontend/test/uxbox/tests/test_main_data_shapes_impl.cljs b/frontend/test/uxbox/tests/test_main_data_shapes_impl.cljs deleted file mode 100644 index 2d634a51b..000000000 --- a/frontend/test/uxbox/tests/test_main_data_shapes_impl.cljs +++ /dev/null @@ -1,126 +0,0 @@ -(ns uxbox.tests.test-main-data-shapes-impl - #_(:require [cljs.test :as t :include-macros true] - [cljs.pprint :refer [pprint]] - [uxbox.util.uuid :as uuid] - [uxbox.main.data.shapes :as impl])) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Duplicate (one shape) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -;; (defn constantly-inc -;; [init] -;; (let [v (atom init)] -;; (fn [& args] -;; (let [result @v] -;; (swap! v inc) -;; result)))) - -;; ;; duplicate shape: duplicate simple shape -;; (t/deftest duplicate-shapes-test1 -;; (let [initial {:pages {1 {:id 1 :shapes [1]}} -;; :shapes {1 {:id 1 :page 1 :name "a"}}} - -;; expected (-> initial -;; (assoc-in [:pages 1 :shapes] [2 1]) -;; (assoc-in [:shapes 2] {:id 2 :page 1 :name "a-copy-1"}))] - -;; (with-redefs [uxbox.util.uuid/random (constantly 2)] -;; (let [result (impl/duplicate-shapes initial [1])] -;; ;; (pprint expected) -;; ;; (pprint result) -;; (t/is (= result expected)))))) - -;; ;; duplicate shape: duplicate inside group -;; (t/deftest duplicate-shapes-test2 -;; (let [initial {:pages {1 {:id 1 :shapes [1]}} -;; :shapes {1 {:id 1 :name "1" :page 1 -;; :type :group -;; :items [2 3]} -;; 2 {:id 2 :name "2" :page 1 :group 1} -;; 3 {:id 3 :name "3" :page 1 :group 1}}} - -;; expected (-> initial -;; (assoc-in [:shapes 1 :items] [5 4 2 3]) -;; (assoc-in [:shapes 4] {:id 4 :name "3-copy-1" :page 1 :group 1}) -;; (assoc-in [:shapes 5] {:id 5 :name "2-copy-1" :page 1 :group 1}))] -;; (with-redefs [uxbox.util.uuid/random (constantly-inc 4)] -;; (let [result (impl/duplicate-shapes initial [2 3])] -;; ;; (pprint expected) -;; ;; (pprint result) -;; (t/is (= result expected)))))) - -;; ;; duplicate shape: duplicate mixed bag -;; (t/deftest duplicate-shapes-test3 -;; (let [initial {:pages {1 {:id 1 :shapes [1 4]}} -;; :shapes {1 {:id 1 :name "1" :page 1 -;; :type :group -;; :items [2 3]} -;; 2 {:id 2 :name "2" :page 1 :group 1} -;; 3 {:id 3 :name "3" :page 1 :group 1} -;; 4 {:id 4 :name "4" :page 1}}} - -;; expected (-> initial -;; (assoc-in [:pages 1 :shapes] [6 5 1 4]) -;; (assoc-in [:shapes 5] {:id 5 :name "4-copy-1" :page 1}) -;; (assoc-in [:shapes 6] {:id 6 :name "3-copy-1" :page 1}))] -;; (with-redefs [uxbox.util.uuid/random (constantly-inc 5)] -;; (let [result (impl/duplicate-shapes initial [3 4])] -;; ;; (pprint expected) -;; ;; (pprint result) -;; (t/is (= result expected)))))) - -;; ;; duplicate shape: duplicate one group -;; (t/deftest duplicate-shapes-test4 -;; (let [initial {:pages {1 {:id 1 :shapes [1]}} -;; :shapes {1 {:id 1 -;; :name "1" -;; :page 1 -;; :type :group -;; :items [2]} -;; 2 {:id 2 -;; :name "2" -;; :page 1 -;; :group 1}}} - -;; expected (-> initial -;; (assoc-in [:pages 1 :shapes] [3 1]) -;; (assoc-in [:shapes 3] {:id 3 -;; :name "1-copy-1" -;; :page 1 -;; :type :group -;; :items [4]}) -;; (assoc-in [:shapes 4] {:id 4 -;; :name "2-copy-1" -;; :page 1 -;; :group 3}))] -;; (with-redefs [uxbox.util.uuid/random (constantly-inc 3)] -;; (let [result (impl/duplicate-shapes initial [1])] -;; ;; (pprint expected) -;; ;; (pprint result) -;; (t/is (= result expected)))))) - -;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; Delete Shape -;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -;; ;; delete shape: delete from page -;; (t/deftest delete-shape-test1 -;; (let [initial {:pages {1 {:id 1 :shapes [1 3 4]}} -;; :shapes {1 {:id 1 :page 1 -;; :type :group -;; :items [2]} -;; 2 {:id 2 :page 1 :group 1} -;; 3 {:id 3 :page 1} -;; 4 {:id 4 :page 1}}} - -;; shape (get-in initial [:shapes 4]) -;; expected {:pages {1 {:id 1 :shapes [1 3]}} -;; :shapes {1 {:id 1 :page 1 :type :group :items [2]} -;; 2 {:id 2 :page 1 :group 1} -;; 3 {:id 3 :page 1}}} - -;; result (impl/dissoc-shape initial shape)] -;; ;; (pprint expected) -;; ;; (pprint result) -;; (t/is (= result expected)))) diff --git a/frontend/test/uxbox/tests/test_util_geom.cljs b/frontend/tests/uxbox/test_util_geom.cljs similarity index 94% rename from frontend/test/uxbox/tests/test_util_geom.cljs rename to frontend/tests/uxbox/test_util_geom.cljs index dbd45d453..b9db6defe 100644 --- a/frontend/test/uxbox/tests/test_util_geom.cljs +++ b/frontend/tests/uxbox/test_util_geom.cljs @@ -1,8 +1,6 @@ -(ns uxbox.tests.test-util-geom +(ns uxbox.test-util-geom (:require [cljs.test :as t :include-macros true] [cljs.pprint :refer [pprint]] - ;; [uxbox.util.geom.point-impl :as gpt2] - ;; [uxbox.util.geom.matrix-impl :as gmt2] [uxbox.util.geom.point :as gpt] [uxbox.util.geom.matrix :as gmt]))