Skip to content

Commit

Permalink
Update test to doo and cljs.test
Browse files Browse the repository at this point in the history
  • Loading branch information
shen-tian committed Nov 21, 2018
1 parent 33f3119 commit 60f3b96
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 28 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ pom.xml.asc
*.class
/.lein-*
/.nrepl-port
/out
9 changes: 5 additions & 4 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[org.clojure/clojurescript "1.9.494" :scope "provided"]]

:aliases {"deploy" ["do" "clean," "deploy" "clojars"]
"test" ["do" "clean," "with-profile" "dev" "cljsbuild" "test"]}
"test" ["do" "clean," "doo" "phantom" "test" "once"]}

:lein-release {:deploy-via :shell
:shell ["lein" "deploy"]}
Expand All @@ -18,9 +18,9 @@

:source-paths ["src"]

:profiles {:dev {:dependencies [[secretary "1.2.1"]]
:plugins [[lein-cljsbuild "1.1.5"]
[com.cemerick/clojurescript.test "0.3.3"]]
:profiles {:dev {:dependencies [[secretary "1.2.3"]]
:plugins [[lein-cljsbuild "1.1.7"]
[lein-doo "0.1.10"]]

:cljsbuild
{:test-commands
Expand All @@ -29,5 +29,6 @@
:builds
{:test {:source-paths ["src" "test"]
:compiler {:output-to "target/unit-test.js"
:main pushy.test.runner
:optimizations :whitespace
:pretty-print true}}}}}})
48 changes: 24 additions & 24 deletions test/pushy/test/core.cljs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
(ns pushy.test.core
(:require-macros
[cemerick.cljs.test :refer (is deftest done use-fixtures)])
(:require
[clojure.test :refer [deftest is async] :as test]
[pushy.core :as pushy]
[secretary.core :as secretary :refer-macros [defroute]]
[goog.events :as events]
[cemerick.cljs.test :as t])
[goog.events :as events])
(:import goog.history.Html5History))

(secretary/set-config! :prefix "/")
Expand All @@ -32,25 +30,27 @@
(is (pushy/supported?)))

;; event listeners started = dispatch
(deftest ^:async push-state-foo-route
(reset! test-val false)
(pushy/start! history)
(pushy/replace-token! history "/foo")
(js/setTimeout
(fn []
(is @test-val)
(is (nil? (pushy/stop! history)))
(is (= "/foo" (pushy/get-token history)))
(done))
5000))
(deftest push-state-foo-route
(async done
(reset! test-val false)
(pushy/start! history)
(pushy/replace-token! history "/foo")
(js/setTimeout
(fn []
(is @test-val)
(is (nil? (pushy/stop! history)))
(is (= "/foo" (pushy/get-token history)))
(done))
5000)))

;; no event listeners started = no dispatch
(deftest ^:async push-state-bar-route
(reset! test-val false)
(pushy/replace-token! history "/bar")
(js/setTimeout
(fn []
(is (false? @test-val))
(is (= "/bar" (pushy/get-token history)))
(done))
5000))
(deftest push-state-bar-route
(async done
(reset! test-val false)
(pushy/replace-token! history "/bar")
(js/setTimeout
(fn []
(is (false? @test-val))
(is (= "/bar" (pushy/get-token history)))
(done))
5000)))
6 changes: 6 additions & 0 deletions test/pushy/test/runner.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(ns pushy.test.runner
(:require [doo.runner :refer-macros [doo-tests]]
[pushy.test.core]))


(doo-tests 'pushy.test.core)

0 comments on commit 60f3b96

Please sign in to comment.