Added unit tests
This commit is contained in:
parent
d71cc7a121
commit
c85093d6ac
16
project.clj
16
project.clj
|
@ -6,4 +6,18 @@
|
|||
:dependencies [[org.clojure/clojure "1.8.0"]
|
||||
[hiccup "1.0.5"]
|
||||
[markdown-clj "0.9.99" :exclusions [com.keminglabs/cljx]]
|
||||
[net.sf.cssbox/swingbox "1.0"]])
|
||||
[net.sf.cssbox/swingbox "1.0"]]
|
||||
:plugins [[lein-codox "0.10.3"]
|
||||
[lein-kibit "0.1.6"]
|
||||
[lein-release "1.0.5"]]
|
||||
:release-tasks [["vcs" "assert-committed"]
|
||||
["change" "version" "leiningen.release/bump-version" "release"]
|
||||
["vcs" "commit"]
|
||||
["clean"]
|
||||
["test"]
|
||||
["codox"]
|
||||
["jar"]
|
||||
;; ["deploy" "clojars"]
|
||||
["change" "version" "leiningen.release/bump-version"]
|
||||
["vcs" "commit"]]
|
||||
)
|
||||
|
|
|
@ -44,7 +44,8 @@
|
|||
* literally anything else.
|
||||
Returns the `window`."
|
||||
[window content]
|
||||
(if (window? window)
|
||||
(if
|
||||
(window? window)
|
||||
(let [browser (:browser window)
|
||||
url (try (.toURL (URI/create (str content))) (catch Exception _ nil))
|
||||
html (try (html content) (catch Exception _ nil))]
|
||||
|
@ -58,14 +59,16 @@
|
|||
java.lang.String (.setText browser content)
|
||||
clojure.lang.PersistentVector (.setText browser (html content))
|
||||
java.io.File (.setPage browser (.toURL content))
|
||||
(.setText browser (str content))))
|
||||
window)))
|
||||
(.setText browser (str content))))))
|
||||
window)
|
||||
|
||||
(defn set-content-markdown
|
||||
"Set the content of this `window` to the markdown read from this `filename`.
|
||||
Return the `window`."
|
||||
[window filename]
|
||||
(set-content window (md/md-to-html-string (slurp filename)))
|
||||
(if
|
||||
(window? window)
|
||||
(set-content window (md/md-to-html-string (slurp filename))))
|
||||
window)
|
||||
|
||||
(defn set-visible
|
||||
|
@ -87,5 +90,3 @@
|
|||
[title content]
|
||||
(set-visible (set-content (create-window title) content)))
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,31 @@
|
|||
(:require [clojure.test :refer :all]
|
||||
[swingbox-clj.core :refer :all]))
|
||||
|
||||
(deftest a-test
|
||||
(testing "FIXME, I fail."
|
||||
(is (= 0 1))))
|
||||
(deftest create-window-test
|
||||
(testing "Creating a window"
|
||||
(let [expected true
|
||||
actual (window? (create-window))] ;; no title
|
||||
(is (= actual expected)))
|
||||
(let [expected true
|
||||
actual (window? (create-window "With title"))]
|
||||
(is (= actual expected)))
|
||||
))
|
||||
|
||||
(deftest is-window-test
|
||||
(testing "window?"
|
||||
(let [expected false
|
||||
actual (window? {:foo :bar})]
|
||||
(is (= actual expected) "Wrong keys"))
|
||||
(let [expected false
|
||||
actual (window? nil)]
|
||||
(is (= actual expected) "Not a map at all"))
|
||||
(let [expected false
|
||||
actual (window? {:frame 7 :browser "Bingo"})]
|
||||
(is (= actual expected) "Wrong values for right keys"))
|
||||
(let [expected true
|
||||
actual (window? (create-window))]
|
||||
(is (= actual expected) "Right keys"))
|
||||
(let [expected true
|
||||
actual (window? (assoc (create-window) :foo "bar"))]
|
||||
(is (= actual expected) "Additional keys are tolerated"))))
|
||||
|
||||
|
|
Loading…
Reference in a new issue