Skip to content

Commit

Permalink
test cofx validation failure
Browse files Browse the repository at this point in the history
  • Loading branch information
mccraigmccraig committed May 19, 2023
1 parent 6c12c3d commit 89fa17e
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/a_frame/cofx_test.cljc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(ns a-frame.cofx-test
(:require
[promesa.core :as pr]
[promisespromises.promise :as prpr]
[promisespromises.test :refer [deftest is testing use-fixtures]]
[a-frame.schema :as schema]
[a-frame.registry :as registry]
Expand Down Expand Up @@ -129,6 +130,32 @@
schema/a-frame-coeffects {cofx-key 100})
(apply dissoc int-r interceptor-chain/context-keys)))))

(testing "invalid 0-arg cofx"
(pr/let [cofx-key ::inject-validated-cofx-test-0-arg-invalid

_ (sut/reg-cofx cofx-key (fn [app _cofx]
(is (= ::app app))
100))

init-int-ctx {}

interceptors [(sut/inject-validated-cofx
cofx-key
:string
cofx-key)]

[k e] (prpr/merge-always
(interceptor-chain/execute
::app
::a-frame
interceptors
init-int-ctx))]

(is (= ::prpr/error k))

(is (= :a-frame.cofx/invalid-cofx
(-> e ex-cause ex-data :error/type)))))

(testing "1-arg cofx"
(pr/let [cofx-key ::inject-validated-cofx-test-1-arg
_ (sut/reg-cofx cofx-key (fn [app _cofx arg]
Expand Down

0 comments on commit 89fa17e

Please sign in to comment.