Create a gist now

Instantly share code, notes, and snippets.

;; This is a clojure.test test case which enters a value in a form
;; field in the browser, clicks the submit button and checks that the
;; correct information is displayed in the page and that the client
;; and server state is as it should be. 'database' is an atom in the
;; server and 'state' is an atom in the browser.
(deftest test-enter-name
(reset! database #{})
;; evaluate two forms in the browser in the start.view namespace
(cljs-eval start.view
(dom/set-value :name-input "Ted")
(dom/click-element :greet-button))
(pause)
;; check the current value of the :name element is "Ted"
(is (= (cljs-eval start.view (.innerHTML (dom/get-element :name)))
"Ted"))
;; check the state atom in the browser
(is (= (cljs-eval start.model @state)
{:state :greeting, :name "Ted", :exists false}))
;; check that the name "Ted" is in the database atom on the server
(is (true? (contains? @database "Ted"))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment