This commit is contained in:
2022-04-26 17:05:58 -07:00
parent cae28589d2
commit 96a796522c
7 changed files with 48 additions and 71 deletions

View File

@@ -48,34 +48,9 @@
{:db/id "client"
:client/code "DEF"}]))]
(testing "it should find vendors"
(let [result (sut2/get-graphql {} {} {})]
(is (= 1 (count result)))))
(testing "It should count invoice usages for each client"
@(d/transact (d/connect uri)
[{:invoice/client client
:invoice/invoice-number "123"
:invoice/vendor vendor}])
(let [result (sut2/get-graphql {:id (admin-token)} {} {})]
(is (= [{:client_id client
:count 1}] (-> result first :usage)))))
(is ((into #{} (map :id (:vendors result))) vendor ))))
(testing "It should count transaction usages for each client"
@(d/transact (d/connect uri)
[{:transaction/client client
:transaction/vendor vendor}])
(let [result (sut2/get-graphql {:id (admin-token)} {} {})]
(is (= [{:client_id client
:count 2}] (-> result first :usage)))))
(testing "It should limit usages to visible clients"
(let [result (sut2/get-graphql {:id (user-token client)} {} {})]
(is (= [{:client_id client
:count 2}] (-> result first :usage))))
(let [result (sut2/get-graphql {:id (user-token 0)} {} {})]
(is (= nil (-> result first :usage))))))))
)))