-
-
Save currentoor/8c482c1440ca0fb1dfae24a305fca070 to your computer and use it in GitHub Desktop.
This file contains 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
(defmutation add-n | |
[{:keys [n]}] | |
(action [{:keys [state]}] | |
(swap! state update :counter + n))) | |
;; This simulates the app state | |
(def st (atom {:counter 0})) | |
;; First arg is the env, second is the mutation name, third is the params | |
(fulcro.client.mutations/mutate {:state st} `add-n {:n 3}) | |
;; => {:action #object[Function]} | |
(let [{:keys [action]} (fulcro.client.mutations/mutate {:state st} `add-n {:n 3}) ] | |
(action)) | |
;; Now in tests you can verify the state has been updated | |
@st | |
;; => {:counter 3} | |
(defn run-mutation [sym params] | |
(let [{:keys [action]} (fulcro.client.mutations/mutate {:state st} sym params)] | |
(action))) | |
;; Same effect as the above code | |
(run-mutation `add-n {:n 3}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment