From d844f4a1f406cddad9158858c1700487ddc9c1e9 Mon Sep 17 00:00:00 2001 From: Bruce Hauman Date: Sun, 24 Jun 2018 17:27:36 -0400 Subject: [PATCH] allow nil app node id --- README.md | 3 ++- src/cljs_test_display/core.cljs | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ffa2791..40b6d82 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ browser you can use `cljs-test-display`. -* Numbered stacktraces for exceptions in the dev console +* Numbered stacktraces for test exceptions in the dev console @@ -40,6 +40,7 @@ browser you can use `cljs-test-display`. * Straightforward integration ```clojure +;; where "app" is the HTML node where you want to mount the tests (cljs.test/run-tests (cljs-test.display.core/init! "app") ;;<-- initialize cljs-test-display here 'example.foo-test diff --git a/src/cljs_test_display/core.cljs b/src/cljs_test_display/core.cljs index 000b0f5..4100013 100644 --- a/src/cljs_test_display/core.cljs +++ b/src/cljs_test_display/core.cljs @@ -400,17 +400,17 @@ 'example.core-other-test)" ([] (init! nil)) ([app-node-id] - (assert (or (string? app-node-id) - (symbol? app-node-id) - (keyword? app-node-id)) - "Must provide an something we can call cljs.core/name on.") - (assert (gdom/getElement (name app-node-id)) + (when app-node-id + (assert (or (string? app-node-id) + (symbol? app-node-id) + (keyword? app-node-id)) + "Must provide an something we can call cljs.core/name on.") + (set! root-node-id (name app-node-id))) + (assert (gdom/getElement (name root-node-id)) (str "cljs-test-display: Element with id " (pr-str root-node-id) " does not exist.")) (when notifications (notify/ask-permission!)) - (when app-node-id - (set! root-node-id (name app-node-id))) (insert-style!) (register-document-events!) (set! (.-innerHTML (root-app-node)) "")