implemented crud
This commit is contained in:
@@ -1,15 +1,34 @@
|
||||
(ns test.auto-ap.graphql
|
||||
(:require [auto-ap.graphql :as sut]
|
||||
[venia.core :as v]
|
||||
[clojure.test :as t :refer [deftest is testing]]))
|
||||
|
||||
(deftest query
|
||||
(testing "it should find rules"
|
||||
(let [result (:transaction-rule-page (:data (sut/query nil "{ transaction_rule_page(client_id: null) { count, start, transaction_rules { id } }}")))]
|
||||
(is (int? (:count result)))
|
||||
(is (int? (:start result)))
|
||||
(is (seqable? (:transaction-rules result)))))
|
||||
(testing "ledger"
|
||||
(testing "it should find ledger entries"
|
||||
(let [result (:ledger-page (:data (sut/query nil "{ ledger_page(client_id: null) { count, start, journal_entries { id } }}")))]
|
||||
(is (int? (:count result)))
|
||||
(is (int? (:start result)))
|
||||
(is (seqable? (:journal-entries result))))))
|
||||
|
||||
(testing "it should find ledger entries"
|
||||
(is (= {:data {:ledger-page {:count 100}}}
|
||||
(sut/query nil "{ ledger_page(client_id: null) { count }}")))))
|
||||
(testing "transaction-rules"
|
||||
(testing "it should find rules"
|
||||
(let [result (-> (sut/query nil "{ transaction_rule_page(client_id: null) { count, start, transaction_rules { id } }}")
|
||||
:data
|
||||
:transaction-rule-page)]
|
||||
(is (int? (:count result)))
|
||||
(is (int? (:start result)))
|
||||
(is (seqable? (:transaction-rules result)))))
|
||||
|
||||
(testing "it should add rules"
|
||||
(let [q (v/graphql-query {:venia/operation {:operation/type :mutation
|
||||
:operation/name "UpsertTransactionRule"}
|
||||
:venia/queries [{:query/data (sut/->graphql [:upsert-transaction-rule
|
||||
{:transaction-rule {:description "123"}}
|
||||
[:id :description]])}]})
|
||||
result (-> (sut/query nil q)
|
||||
:data
|
||||
:upsert-transaction-rule)]
|
||||
(is (= "123" (:description result)))
|
||||
(is (:id result))))))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user