Skip to content

Commit

Permalink
async
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Jun 21, 2024
1 parent ea82cd1 commit 700a440
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion test/squint/html_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
[clojure.test :as t :refer [deftest is]]
[squint.test-utils :refer [jss! jsv!]]
[squint.compiler :as squint]
[clojure.string :as str]))
[clojure.string :as str]
[promesa.core :as p]))

(deftest html-test
(t/async done
Expand Down Expand Up @@ -87,7 +88,24 @@
(.catch #(is false "nooooo"))
(.finally done)))))

(defn compile-html [s]
(let [js (squint.compiler/compile-string s
{:repl true :elide-exports true :context :return})
js (str/replace "(async function() { %s } )()" "%s" js)]
js))


(deftest html-safe-test
(t/async done
(->
(p/let [js (compile-html
"(defn foo [x] #html [:div x]) (foo \"<>\")")
v (js/eval js)
_ (is (= "<div>&lt;&gt;</div>" v))])
(p/catch #(is false "nooooo"))
(p/finally done))))

#_(deftest html-safe-test
(t/async done
(let [js (squint.compiler/compile-string
"(defn foo [x] #html [:div x]) (foo \"<>\")"
Expand Down

0 comments on commit 700a440

Please sign in to comment.