Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

making trim-v before/after symmetrical #283

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/re_frame/std_interceptors.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,14 @@
:id :trim-v
:before (fn trimv-before
[context]
(update-in context [:coeffects :event] subvec 1))))
(-> context
(update-in [:coeffects :event] subvec 1)
(assoc-in [:coeffects ::untrimmed-event] (get-coeffect context :event))))
:after (fn trimv-after
[context]
(-> context
(assoc-in [:coeffects :event] (get-coeffect context ::untrimmed-event))
(update :coeffects dissoc ::untrimmed-event)))))


;; -- Interceptor Factories - PART 1 ---------------------------------------------------------------
Expand Down Expand Up @@ -279,5 +286,3 @@
(assoc-in new-db out-path)
(assoc-effect context :db))
context)))))


10 changes: 6 additions & 4 deletions test/re-frame/interceptor_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
(enable-console-print!)

(deftest test-trim-v
(let [c (-> (context [:a :b :c] [])
((:before trim-v)))]
(let [ctx (context [:a :b :c] [])
c ((:before trim-v) ctx)]
(is (= (get-coeffect c :event)
[:b :c]))))
[:b :c]))

(let [c-after ((:after trim-v) c)]
(is (= c-after ctx)))))


(deftest test-one-level-path
Expand Down Expand Up @@ -125,7 +128,6 @@
((:after change-i))
(get-effect :db))))))


(deftest test-after
(testing "when no db effect is returned"
(let [after-db-val (atom nil)]
Expand Down