Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanmikaelian committed Aug 9, 2024
1 parent a9214a1 commit 238d18d
Showing 1 changed file with 41 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
(ns com.vennbilling.customer.interface-test
(:require
[clojure.test :as test :refer [deftest testing is]]
[com.vennbilling.customer.interface :as customer]))
[com.vennbilling.customer.interface :as customer]
[ring.util.http-status :as http-status]))


(deftest customer-test
(deftest testing-customer
(testing "Customer"
(testing "with identifier"
(is (= "abc" (:identifier (customer/make-customer "abc" {} {})))))
Expand All @@ -26,3 +27,41 @@

(testing "with xt/id"
(is (= false (nil? (:xt/id (customer/make-customer "abc" {} {}))))))))


(deftest testing-routes
(testing "List"
(let [[path route] customer/list-route]
(testing "path"
(is (= "/customers" path)))


(testing "http"
(testing "GET request"
(testing "handler function"
(let [{{:keys [handler]} :get} route
resp (handler {})
{:keys [status body]} resp
customer (first body)
{:keys [identifier traits billing-provider]} customer]
(is (= http-status/ok status))
(is (= "1" identifier))
(is (= {} traits))
(is (= {} billing-provider))))))))

(testing "Show"
(let [[path route] customer/show-route]
(testing "path"
(is (= "/customers/:id" path)))

(testing "http"
(testing "GET request"
(testing "handler function"
(let [{{:keys [handler]} :get} route
resp (handler {:path-params {:id "1"}})
{:keys [status body]} resp
{:keys [identifier traits billing-provider]} body]
(is (= http-status/ok status))
(is (= "1" identifier))
(is (= {} traits))
(is (= {} billing-provider)))))))))

0 comments on commit 238d18d

Please sign in to comment.