Skip to content

Commit

Permalink
Add clj, cljs and cljc tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kauko committed Oct 12, 2017
1 parent 85ed75f commit 4e47f61
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/clj/widgetshop/example_test.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(ns widgetshop.example-test
(:require [clojure.test :refer :all]))

(deftest foobar
(is (= 1 1)))
27 changes: 27 additions & 0 deletions test/cljs/widgetshop/app/products_test.cljs
Original file line number Diff line number Diff line change
@@ -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}})))



7 changes: 7 additions & 0 deletions test/cljs/widgetshop/test_runner.cljs
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 4e47f61

Please sign in to comment.