mirror of
https://github.com/penpot/penpot.git
synced 2025-05-31 08:06:11 +02:00
Add grouping function by type
This commit is contained in:
parent
3c67872d3c
commit
62ecee2cf8
2 changed files with 47 additions and 18 deletions
|
@ -29,24 +29,33 @@
|
|||
(t/is (= #{:x} (wtt/token-applied-attributes {:id :a}
|
||||
{:applied-tokens {:x :a :y :b}}
|
||||
#{:x :missing}))))
|
||||
(comment
|
||||
(let [test-fn (fn [& args])]
|
||||
(t/deftest token-context-menu
|
||||
(let [shapes [{:applied-tokens {:x :a
|
||||
:y :a}}
|
||||
{:applied-tokens {:x :a
|
||||
:y :a}}]]
|
||||
(t/is (= :all (test-fn {:id :a} shapes #{:x :y}))))
|
||||
(let [shapes [{:applied-tokens {:x :a
|
||||
:y :_}}
|
||||
{:applied-tokens {:x :_
|
||||
:y :a}}]]
|
||||
(t/is (= #{:x :y} (test-fn {:id :a} shapes #{:x :y}))))
|
||||
(let [shapes [{:applied-tokens {:x :a
|
||||
:y :_}}
|
||||
{:applied-tokens {:x :a
|
||||
:y :_}}]]
|
||||
(t/is (= #{:x} (test-fn {:id :a} shapes #{:x})))))))
|
||||
(t/deftest token-context-menu
|
||||
(t/testing "Returns :all when token is applied to every shape"
|
||||
(let [shapes [{:applied-tokens {:x 1 :y 1}}
|
||||
{:applied-tokens {:x 1 :y 1}}]
|
||||
expected (wtt/group-shapes-by-all-applied {:id 1} shapes #{:x :y})]
|
||||
(t/is (= (:all expected) shapes))
|
||||
(t/is (empty? (:other expected)))
|
||||
(t/is (empty? (:some expected)))))
|
||||
|
||||
(t/testing "Returns set of matched attributes that fit the applied token"
|
||||
(let [attributes #{:x :y :z}
|
||||
shape-applied-x {:applied-tokens {:x 1}}
|
||||
shape-applied-y {:applied-tokens {:y 1}}
|
||||
shape-applied-x-y {:applied-tokens {:x 1 :y 1}}
|
||||
shape-applied-none {:applied-tokens {}}
|
||||
shape-applied-all {:applied-tokens {:x 1 :y 1 :z 1}}
|
||||
shapes [shape-applied-x
|
||||
shape-applied-y
|
||||
shape-applied-x-y
|
||||
shape-applied-all
|
||||
shape-applied-none]
|
||||
expected (wtt/group-shapes-by-all-applied {:id 1} shapes attributes)]
|
||||
(t/is (= (:all expected) [shape-applied-all]))
|
||||
(t/is (= (:none expected) [shape-applied-none]))
|
||||
(t/is (= (get-in expected [:some :x]) [shape-applied-x shape-applied-x-y]))
|
||||
(t/is (= (get-in expected [:some :y]) [shape-applied-y shape-applied-x-y]))
|
||||
(t/is (nil? (get-in expected [:some :z]))))))
|
||||
|
||||
(t/deftest tokens-applied-test
|
||||
(t/testing "is true when single shape matches the token and attributes"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue