mirror of
https://github.com/penpot/penpot.git
synced 2025-01-21 06:02:32 -05:00
Add stroke-width test
This commit is contained in:
parent
2a97749d23
commit
c9d1fe44e9
1 changed files with 33 additions and 0 deletions
|
@ -212,6 +212,39 @@
|
|||
(t/is (= (:rotation (:applied-tokens rect-1')) (:id token-target')))
|
||||
(t/is (= (:rotation rect-1') 120)))))))))
|
||||
|
||||
(t/deftest test-apply-stroke-width
|
||||
(t/testing "applies stroke-width token and updates the shapes with stroke"
|
||||
(t/async
|
||||
done
|
||||
(let [file (-> (setup-file {:rect-1 {:strokes [{:stroke-alignment :inner,
|
||||
:stroke-style :solid,
|
||||
:stroke-color "#000000",
|
||||
:stroke-opacity 1,
|
||||
:stroke-width 5}]}})
|
||||
(toht/add-token :token-target {:value "10"
|
||||
:name "stroke-width.sm"
|
||||
:type :stroke-width}))
|
||||
store (ths/setup-store file)
|
||||
rect-with-stroke (cths/get-shape file :rect-1)
|
||||
rect-without-stroke (cths/get-shape file :rect-2)
|
||||
events [(wtch/apply-token {:shape-ids [(:id rect-with-stroke) (:id rect-without-stroke)]
|
||||
:attributes #{:stroke-width}
|
||||
:token (toht/get-token file :token-target)
|
||||
:on-update-shape wtch/update-stroke-width})]]
|
||||
(tohs/run-store-async
|
||||
store done events
|
||||
(fn [new-state]
|
||||
(let [file' (ths/get-file-from-store new-state)
|
||||
token-target' (toht/get-token file' :token-target)
|
||||
rect-with-stroke' (cths/get-shape file' :rect-1)
|
||||
rect-without-stroke' (cths/get-shape file' :rect-2)]
|
||||
(t/testing "token got applied to rect with stroke and shape stroke got updated"
|
||||
(t/is (= (:stroke-width (:applied-tokens rect-with-stroke')) (:id token-target')))
|
||||
(t/is (= (get-in rect-with-stroke' [:strokes 0 :stroke-width]) 10)))
|
||||
(t/testing "token got applied to rect without stroke but shape didnt get updated"
|
||||
(t/is (= (:stroke-width (:applied-tokens rect-without-stroke')) (:id token-target')))
|
||||
(t/is (empty? (:strokes rect-without-stroke')))))))))))
|
||||
|
||||
(t/deftest test-toggle-token-none
|
||||
(t/testing "should apply token to all selected items, where no item has the token applied"
|
||||
(t/async
|
||||
|
|
Loading…
Add table
Reference in a new issue