update examples. fix bugs

This commit is contained in:
2026-02-03 12:53:52 -05:00
parent 9150c90ad1
commit 426a0c4715
15 changed files with 867 additions and 1148 deletions
+9 -9
View File
@@ -9,14 +9,14 @@
(testing "quit returns quit event"
(is (= {:type :quit} (ev/quit)))))
(deftest delay-test
(testing "delay creates delay event"
(is (= {:type :delay :ms 1000 :event {:type :tick}}
(ev/delay 1000 {:type :tick}))))
(deftest delayed-event-test
(testing "delayed-event creates delayed-event event"
(is (= {:type :delayed-event :ms 1000 :event {:type :tick}}
(ev/delayed-event 1000 {:type :tick}))))
(testing "delay with different ms values"
(is (= 0 (:ms (ev/delay 0 {:type :x}))))
(is (= 5000 (:ms (ev/delay 5000 {:type :x}))))))
(testing "delayed-event with different ms values"
(is (= 0 (:ms (ev/delayed-event 0 {:type :x}))))
(is (= 5000 (:ms (ev/delayed-event 5000 {:type :x}))))))
(deftest shell-test
(testing "shell creates shell event with vector cmd"
@@ -124,11 +124,11 @@
(testing "can compose multiple event constructors"
(let [result (ev/batch
(ev/shell ["git" "status"] {:type :status})
(ev/delay 1000 {:type :refresh}))]
(ev/delayed-event 1000 {:type :refresh}))]
(is (= :batch (:type result)))
(is (= 2 (count (:events result))))
(is (= :shell (:type (first (:events result)))))
(is (= :delay (:type (second (:events result)))))))
(is (= :delayed-event (:type (second (:events result)))))))
(testing "can nest batch in sequential"
(let [result (ev/sequential