From 4e47f6163aedad9b6cf910b00e91e835c671eccf Mon Sep 17 00:00:00 2001 From: Teemu Kaukoranta Date: Thu, 12 Oct 2017 09:58:49 +0300 Subject: [PATCH] Add clj, cljs and cljc tests --- test/clj/widgetshop/example_test.clj | 5 ++++ test/cljs/widgetshop/app/products_test.cljs | 27 +++++++++++++++++++++ test/cljs/widgetshop/test_runner.cljs | 7 ++++++ 3 files changed, 39 insertions(+) create mode 100644 test/clj/widgetshop/example_test.clj create mode 100644 test/cljs/widgetshop/app/products_test.cljs create mode 100644 test/cljs/widgetshop/test_runner.cljs diff --git a/test/clj/widgetshop/example_test.clj b/test/clj/widgetshop/example_test.clj new file mode 100644 index 0000000..3c492d5 --- /dev/null +++ b/test/clj/widgetshop/example_test.clj @@ -0,0 +1,5 @@ +(ns widgetshop.example-test + (:require [clojure.test :refer :all])) + +(deftest foobar + (is (= 1 1))) \ No newline at end of file diff --git a/test/cljs/widgetshop/app/products_test.cljs b/test/cljs/widgetshop/app/products_test.cljs new file mode 100644 index 0000000..e953134 --- /dev/null +++ b/test/cljs/widgetshop/app/products_test.cljs @@ -0,0 +1,27 @@ +(ns widgetshop.app.products-test + (:require [cljs.test :as test :refer-macros [deftest is testing]] + [widgetshop.app.products :as p])) + +(deftest products-by-category + (testing "Value is set to the right path" + (is (= (p/products-by-category {} :foo [1 2 3]) + {:products-by-category {:foo [1 2 3]}})))) + +(deftest setting-categories + (is (= (p/set-categories {:bar :baz} {:foo [] :baz []}) + {:categories {:foo [] :baz []} + :bar :baz}))) + +(deftest loading-products-by-category + (is (= (p/load-products-by-category! + {:categories [{:id 2 :name :foo} + {:id 1 :name :bar}]} + (constantly "whatever doesn't matter") + 1) + {:category {:id 1 :name :bar} + :categories [{:id 2 :name :foo} + {:id 1 :name :bar}] + :products-by-category {{:id 1 :name :bar} :loading}}))) + + + diff --git a/test/cljs/widgetshop/test_runner.cljs b/test/cljs/widgetshop/test_runner.cljs new file mode 100644 index 0000000..ae307ae --- /dev/null +++ b/test/cljs/widgetshop/test_runner.cljs @@ -0,0 +1,7 @@ +(ns widgetshop.test-runner + (:require [doo.runner :refer-macros [doo-tests]] + [widgetshop.app.products-test])) + +(enable-console-print!) + +(doo-tests 'widgetshop.app.products-test) \ No newline at end of file