File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ (ns eca.features.commands-test
2+ (:require
3+ [clojure.test :refer [deftest is testing]]
4+ [eca.features.commands :as f.commands]))
5+
6+ (deftest get-custom-command-tests
7+ (testing " returns nil when command not found"
8+ (is (nil? (#'f.commands/get-custom-command " nope" [] []))))
9+
10+ (testing " $ARGS is replaced with the joined args"
11+ (let [custom [{:name " greet" :content " Hello $ARGS!" }]]
12+ (is (= " Hello Alice Bob!"
13+ (#'f.commands/get-custom-command " greet" [" Alice" " Bob" ] custom)))))
14+
15+ (testing " numbered $ARGn placeholders are replaced and $ARGS contains all args"
16+ (let [custom [{:name " pair" :content " First:$ARG1 Second:$ARG2 All:$ARGS" }]]
17+ (is (= " First:one Second:two All:one two"
18+ (#'f.commands/get-custom-command " pair" [" one" " two" ] custom)))))
19+
20+ (testing " unmatched placeholders remain when args are missing"
21+ (let [custom [{:name " partial" :content " A:$ARG1 B:$ARG2 C:$ARG3" }]]
22+ (is (= " A:only B: C:$ARG3"
23+ (#'f.commands/get-custom-command " partial" [" only" " " ] custom)))))
24+
25+ (testing " multiple occurrences of the same placeholder are all replaced"
26+ (let [custom [{:name " dup" :content " $ARG1-$ARG1 $ARGS" }]]
27+ (is (= " x-x x y"
28+ (#'f.commands/get-custom-command " dup" [" x" " y" ] custom))))))
You can’t perform that action at this time.
0 commit comments