<commit_before>(ns cover-page.components.contact-form-test
  (:require [cover-page.components.contact-form :as f]
            [cover-page.utils.content :refer [label]]
            [cljs.test :refer-macros [deftest testing is]]))

(deftest send-message-test
  (let [fake-label #(% {:email-form-error-empty-message "no message"
                        :email-form-error-empty-address "no email"
                        :email-form-error-wrong-address "wrong email format"})]
    (testing "Input Validator"
      (binding [label fake-label]
        (is (= ["no message"] (f/validate-input "<EMAIL>" nil)))
        (is (= ["no message"] (f/validate-input "<EMAIL>" "")))
        (is (= nil            (f/validate-input "<EMAIL>" "a message")))))))
<commit_msg>[cover] adding more test cases for user input<commit_after>(ns cover-page.components.contact-form-test
  (:require [cover-page.components.contact-form :as f]
            [cover-page.utils.content :refer [label]]
            [cljs.test :refer-macros [deftest testing is]]))

(deftest send-message-test
  (let [message-found #(boolean (some #{%1} %2))
        fake-label #(% {:email-form-error-empty-address "no email"
                        :email-form-error-empty-message "no message"
                        :email-form-error-wrong-address "wrong email format"})]
    (testing "Input Validator"
      (binding [label fake-label]
        (is (message-found "no message"         (f/validate-input "<EMAIL>" "")))
        (is (message-found "no message"         (f/validate-input "<EMAIL>" nil)))
        (is (message-found "no email"           (f/validate-input ""               "a message")))
        (is (message-found "no email"           (f/validate-input nil              "a message")))
        (is (message-found "wrong email format" (f/validate-input "user"           "a message")))
        (is (message-found "wrong email format" (f/validate-input "user@email"     "a message")))
        (is (message-found "wrong email format" (f/validate-input "@<EMAIL>.com"     "a message")))
        (is (message-found "wrong email format" (f/validate-input "useremail.com"  "a message")))
        (is (empty?                             (f/validate-input "<EMAIL>" "a message")))))))

{'fraction_non_alphanumeric': 0.1631649530621368, 'fraction_numerical': 0.000894054537326777, 'mean_word_length': 2.3402985074626868, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6345821', 'n_tokens_mistral': 687, 'n_tokens_neox': 667, 'n_words': 167}