<commit_before>(ns voke.input-test
  (:require [cljs.core.async :refer [chan <! put!]]
            [cljs.test :refer [async deftest is testing]]
            [goog.events :as events]
            [voke.input :as input])
  (:import [goog.events KeyCodes])
  (:require-macros [cljs.core.async.macros :refer [go]]))

(deftest listen-to-keyboard-inputs
  (async done
    (go
      (let [event-chan (chan)
            event-handlers (atom [])]

        (with-redefs [events/listen (fn [_ _ event-handler-fn]
                                      (swap! event-handlers conj event-handler-fn))]
          (input/listen-to-keyboard-inputs event-chan)

          (let [[down-handler up-handler] @event-handlers
                call-handler (fn [handler key-code]
                               (handler #js {:keyCode        key-code
                                             :preventDefault (fn [])}))

                _ (call-handler down-handler KeyCodes.W)

                voke-input-event (<! event-chan)]
            (is (= voke-input-event
                   {:type      :move-key-down
                    :direction :up})))))

      (done))
    )


  )


(deftest handle-keyboard-events

  )
<commit_msg>test listen-to-keybaord-inputs more thoroughly<commit_after>(ns voke.input-test
  (:require [cljs.core.async :refer [chan <! put!]]
            [cljs.test :refer [async deftest is testing]]
            [goog.events :as events]
            [voke.input :as input])
  (:import [goog.events KeyCodes])
  (:require-macros [cljs.core.async.macros :refer [go]]))

(deftest listen-to-keyboard-inputs
  (async done
    (go
      (let [event-chan (chan)
            event-handlers (atom [])]
        (with-redefs [events/listen (fn [_ _ event-handler-fn]
                                      (swap! event-handlers conj event-handler-fn))]
          (input/listen-to-keyboard-inputs event-chan)

          (let [[down-handler up-handler] @event-handlers
                send-event-to-handler (fn [handler key-code]
                               (handler #js {:keyCode        key-code
                                             :preventDefault (fn [])})) ]

                (testing "basic keydown functionality"
                  (send-event-to-handler down-handler KeyCodes.W)
                  (send-event-to-handler down-handler KeyCodes.A)
                  (is (= (<! event-chan)
                           {:type      :move-key-down
                            :direction :up}))
                  (is (= (<! event-chan)
                           {:type      :move-key-down
                            :direction :left})))

                (testing "basic keyup functionality"
                  (send-event-to-handler up-handler KeyCodes.W)
                  (send-event-to-handler up-handler KeyCodes.A)
                  (is (= (<! event-chan)
                           {:type      :move-key-up
                            :direction :up}))
                  (is (= (<! event-chan)
                           {:type      :move-key-up
                            :direction :left}))))))
      (done))))


(deftest handle-keyboard-events
  )

{'fraction_non_alphanumeric': 0.12841703750794659, 'fraction_numerical': 0.0, 'mean_word_length': 1.3537771129394165, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5869031', 'n_tokens_mistral': 924, 'n_tokens_neox': 879, 'n_words': 184}