(ns auto-ap.integration.graphql.vendors
  (:require
   [auto-ap.datomic :refer [conn]]
   [auto-ap.graphql.vendors :as sut2]
   [auto-ap.integration.util :refer [admin-token wrap-setup]]
   [clojure.test :as t :refer [deftest is testing use-fixtures]]
   [datomic.client.api :as dc]))

(use-fixtures :each wrap-setup)


(deftest vendors
  (testing "vendors"
    (let [{:strs [vendor]} (:tempids (dc/transact conn {:tx-data [{:vendor/name "Test" :db/id "vendor"}
                                                                  {:db/id       "client"
                                                                   :client/code "DEF"}]}))]
      (testing "it should find vendors"
        (let [result (sut2/get-graphql {:id (admin-token)} {} {})]
          (is ((into #{} (map :id (:vendors result))) vendor )))))))


