<commit_before>(ns ohds.socialgroup-test
  (:require  
   [ohds.socialgroup.view :as view]
   [ohds.socialgroup.messages :as m]
   [ohds.socialgroup.processing :as p]
   [ohds.framework :refer [with-mounted-component found-in elem]]
   [cljs-http.client :as http]
   [petrol.core :refer [process-message watch-channels wrap]]
   [cljs.test :refer-macros [deftest is testing run-tests]]))

(deftest socialgroup-test
  (testing "changing external id updates app state"
    (let [msg (m/->ChangeExtId "extid")]
      (is (= {:socialgroup {:extId "extid"}})
          (process-message msg {}))))
  (testing "changing group name updates app state"
    (let [msg (m/->ChangeGroupName "gname")]
      (is (= {:socialgroup {:name "gname"}}
             (process-message msg {})))))
  (testing "changing group type updates app state"
    (let [msg (m/->ChangeGroupType "COHORT")]
      (is (= {:socialgroup {:type "COHORT"}}
             (process-message msg {}))))))<commit_msg>submit social group test<commit_after>(ns ohds.socialgroup-test
  (:require
   [ohds.socialgroup.view :as view]
   [ohds.socialgroup.messages :as m]
   [ohds.socialgroup.processing :as p]
   [ohds.framework :refer [with-mounted-component found-in elem]]
   [cljs-http.client :as http]
   [petrol.core :refer [process-message watch-channels wrap]]
   [cljs.test :refer-macros [deftest is testing run-tests]]))

(deftest socialgroup-test
  (testing "changing external id updates app state"
    (let [msg (m/->ChangeExtId "extid")]
      (is (= {:socialgroup {:extId "extid"}})
          (process-message msg {}))))
  (testing "changing group name updates app state"
    (let [msg (m/->ChangeGroupName "gname")]
      (is (= {:socialgroup {:name "gname"}}
             (process-message msg {})))))
  (testing "changing group type updates app state"
    (let [msg (m/->ChangeGroupType "COHORT")]
      (is (= {:socialgroup {:type "COHORT"}}
             (process-message msg {})))))
  (testing "submitting socialgroup calls backend correctly"
    (let [msg (m/->SubmitSocialGroup)
          app {:fieldworker-id "fw-id"
               :socialgroup {:name "gname"
                             :extId "extId"
                             :type "COHORT"}}]
      (with-redefs [http/post (fn [url body]
                                (is (= {:form-params {:fieldworker-id "fw-id"
                                                      :ext-id "extId"
                                                      :group-name "gname"
                                                      :group-type "COHORT"}}
                                     body))
                                {:status 200
                                 :body "a-uuid"})
                    wrap (fn [m c] (m c))]
        (is (= #{(m/map->CreateSocialGroupResults {:status 200 :body "a-uuid"})}
               (watch-channels msg app)))))))
{'fraction_non_alphanumeric': 0.14623955431754876, 'fraction_numerical': 0.0020891364902506965, 'mean_word_length': 2.046659597030753, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5280724', 'n_tokens_mistral': 878, 'n_tokens_neox': 839, 'n_words': 225}