Created
December 4, 2011 01:07
-
-
Save brentonashworth/1428711 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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