Skip to content
This repository has been archived by the owner on Jun 4, 2022. It is now read-only.

Commit

Permalink
Add symbol with numbers and corner case tests
Browse files Browse the repository at this point in the history
The new tests make sure lumo correctly handles completions for symbols with
numbers (see #333), lines starting with (, ending with / or completely empty.
  • Loading branch information
arichiardi committed Jan 26, 2018
1 parent ec548da commit 1f1a726
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/test/lumo/lumo/repl_tests.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,28 @@
(defn is-completion [i o]
(lumo/get-completions i
(fn [completions]
(is (= (js->clj completions) (sort (into [] (map str) o)))))))
(let [sorted (sort (into [] (map str) o))]
(is (= (js->clj completions) sorted) (str i " should generate the " sorted " completion"))))))

(defn is-contains-completion
([i o]
(is-contains-completion i o identity))
([i o f]
(lumo/get-completions i
(fn [completions]
(is (f (contains? (set completions) o)))))))
(is (f (contains? (set completions) o)) (str i " should generate completions that contain " o))))))

(defn is-empty-completion
[i]
(lumo/get-completions i
(fn [completions]
(is (empty? (set completions)) (str i "should generate no completion")))))

(when test-util/lumo-env?
(deftest test-get-completions
(testing "corner cases"
(is-completion "(" (mapv #(str "(" %) (lumo/completion-candidates true nil)))
(is-completion "" (lumo/completion-candidates false nil)))
(testing "keyword completions"
(is-completion ":" lumo/keyword-completions)
(is-completion ":a" [":args" ":as"])
Expand Down Expand Up @@ -118,7 +128,11 @@
(testing "arbitrary fully qualified keyword"
(s/def :arbitrary/a-spec string?)
(is-contains-completion ":arbitrary/" ":arbitrary/a-spec")
(reset! s/registry-ref {})))))
(reset! s/registry-ref {})))
(testing "prefix filtering"
(with-redefs [lumo/get-namespace (fn []
'{:defs {red6hlolli {:name cljs.user/red6hlolli}}})]
(is-contains-completion "red6" "red6hlolli")))))



Expand Down

0 comments on commit 1f1a726

Please sign in to comment.