Skip to content

Instantly share code, notes, and snippets.

@brentonashworth
Created December 4, 2011 01:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brentonashworth/1428711 to your computer and use it in GitHub Desktop.
Save brentonashworth/1428711 to your computer and use it in GitHub Desktop.
;; 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