-
Notifications
You must be signed in to change notification settings - Fork 10
/
html.cljs
53 lines (45 loc) · 1.6 KB
/
html.cljs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
(ns respo.test.html
(:require [cljs.test :refer [deftest is testing run-tests]]
[respo.macros
:refer
[html head title script style meta' div link body textarea]]
[respo.test.comp.todolist :refer [comp-todolist]]
[respo.render.html :refer [make-string]]
["fs" :as fs]))
(defn slurp [file-path] (.readFileSync fs file-path "utf8"))
(deftest
html-quote-test
(let [tree-demo (div {:value "a\"b\"c", :x "y", :style {:content "d\"e\"f"}})]
(testing
"HTML contains quotes"
(is (= (slurp "test/examples/quote.html") (make-string tree-demo))))))
(def todolist-store [{:id 101, :text "101"} {:id 102, :text "102"}])
(deftest
html-test
(let [todo-demo (comp-todolist todolist-store)]
(testing
"test generated HTML from component"
(is (= (slurp "test/examples/demo.html") (make-string todo-demo))))))
(deftest
simple-html-test
(let [tree-demo (html
{}
(head
{}
(title {:innerHTML "Demo"})
(link {:rel "icon", :type "image/png"})
(script {:innerHTML "{}"}))
(body {} (div {:id "app"} (div {}))))]
(testing
"test generated HTML from tree"
(is (= (slurp "test/examples/simple.html") (make-string tree-demo))))))
(deftest
textarea-test
(let [piece (textarea {:value "a\nb\nc\n\"\nd"})]
(testing
"test generated HTML from component"
(is
(=
"<textarea value=\"a\\nb\\nc\\n"\\nd\">a\nb\nc\n"\nd</textarea>"
(make-string piece))))))
(defn main! [] (run-tests))