mirror of
https://github.com/penpot/penpot.git
synced 2025-01-21 22:22:43 -05:00
Add test to verify toggle removes token for applied & unapplied
This commit is contained in:
parent
ab62c5b4ef
commit
596480d177
1 changed files with 35 additions and 31 deletions
|
@ -89,8 +89,9 @@
|
||||||
(t/is (= (:rx rect-1') 24))
|
(t/is (= (:rx rect-1') 24))
|
||||||
(t/is (= (:ry rect-1') 24))))))))
|
(t/is (= (:ry rect-1') 24))))))))
|
||||||
|
|
||||||
(t/deftest test-toggle-token
|
|
||||||
(t/testing "will apply token to all selected items, where no item has the token applied"
|
(t/deftest test-toggle-token-none
|
||||||
|
(t/testing "should apply token to all selected items, where no item has the token applied"
|
||||||
(t/async
|
(t/async
|
||||||
done
|
done
|
||||||
(let [file (setup-file)
|
(let [file (setup-file)
|
||||||
|
@ -117,25 +118,28 @@
|
||||||
(t/is (= (:rx rect-1') 24))
|
(t/is (= (:rx rect-1') 24))
|
||||||
(t/is (= (:rx rect-2') 24)))))))))
|
(t/is (= (:rx rect-2') 24)))))))))
|
||||||
|
|
||||||
(comment
|
(t/deftest test-toggle-token-mixed
|
||||||
(t/run-tests)
|
(t/testing "should unapply token if one of the selected items has the token applied"
|
||||||
(defn make-printable
|
(t/async
|
||||||
"Convert records that are not printable by cider inspect into regular maps."
|
done
|
||||||
[coll]
|
(let [file (-> (setup-file)
|
||||||
(letfn [(stringifyable? [x]
|
(apply-token-to-shape :rect-1 :token-1 #{:rx :ry}))
|
||||||
(not (or (map? x)
|
store (ths/setup-store file)
|
||||||
(sequential? x)
|
rect-1 (cths/get-shape file :rect-1)
|
||||||
(keyword? x)
|
rect-2 (cths/get-shape file :rect-2)
|
||||||
(number? x)
|
events [(wtc/toggle-token {:shapes [rect-1 rect-2]
|
||||||
(uuid? x))))]
|
:token-type-props {:attributes #{:rx :ry}}})]]
|
||||||
(clojure.walk/postwalk #(cond->> %
|
(tohs/run-store-async
|
||||||
(record? %) (into {})
|
store done events
|
||||||
(stringifyable? %) str)
|
(fn [new-state]
|
||||||
coll)))
|
(let [file' (ths/get-file-from-store new-state)
|
||||||
|
token-2' (get-token file' :token-2)
|
||||||
(-> (cthf/sample-file :file-1)
|
rect-1' (cths/get-shape file' :rect-1)
|
||||||
(assoc :tokens {})
|
rect-2' (cths/get-shape file' :rect-2)]
|
||||||
(make-printable))
|
(t/is (nil? (:rx (:applied-tokens rect-1'))))
|
||||||
|
(t/is (nil? (:ry (:applied-tokens rect-1'))))
|
||||||
(make-printable (setup-file))
|
(t/is (nil? (:rx (:applied-tokens rect-2'))))
|
||||||
nil)
|
(t/is (nil? (:ry (:applied-tokens rect-2'))))
|
||||||
|
;; Verify that shape attributes didn't get changed
|
||||||
|
(t/is (zero? (:rx rect-1')))
|
||||||
|
(t/is (zero? (:rx rect-2'))))))))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue