0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-21 06:02:32 -05:00

Fix sizing test

This commit is contained in:
Florian Schroedl 2024-08-08 15:13:04 +02:00
parent 8b8b909fb7
commit e992bf0aa6

View file

@ -147,33 +147,33 @@
(t/is (= (:width rect-1') 100))
(t/is (= (:height rect-1') 100))))))))))
;; (t/deftest test-apply-sizing
;; (t/testing "applies sizing token and updates the shapes width and height"
;; (t/async
;; done
;; (let [file (-> (setup-file)
;; (toht/add-token :token-target {:value "100"
;; :name "sizing.sm"
;; :type :sizing}))
;; store (ths/setup-store file)
;; rect-1 (cths/get-shape file :rect-1)
;; events [(wtch/apply-token {:shape-ids [(:id rect-1)]
;; :attributes #{:width :height}
;; :token (toht/get-token file :token-target)
;; :on-update-shape wtch/update-shape-dimensions})]]
;; (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-1' (cths/get-shape file' :rect-1)]
;; (t/testing "shape `:applied-tokens` got updated"
;; (t/is (some? (:applied-tokens rect-1')))
;; (t/is (= (:width (:applied-tokens rect-1')) (wtt/token-identifier token-target')))
;; (t/is (= (:height (:applied-tokens rect-1')) (wtt/token-identifier token-target'))))
;; (t/testing "shapes width and height got updated"
;; (t/is (= (:width rect-1') 100))
;; (t/is (= (:height rect-1') 100))))))))))
(t/deftest test-apply-sizing
(t/testing "applies sizing token and updates the shapes width and height"
(t/async
done
(let [file (-> (setup-file)
(toht/add-token :token-target {:value "100"
:name "sizing.sm"
:type :sizing}))
store (ths/setup-store file)
rect-1 (cths/get-shape file :rect-1)
events [(wtch/apply-token {:shape-ids [(:id rect-1)]
:attributes #{:width :height}
:token (toht/get-token file :token-target)
:on-update-shape wtch/update-shape-dimensions})]]
(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-1' (cths/get-shape file' :rect-1)]
(t/testing "shape `:applied-tokens` got updated"
(t/is (some? (:applied-tokens rect-1')))
(t/is (= (:width (:applied-tokens rect-1')) (wtt/token-identifier token-target')))
(t/is (= (:height (:applied-tokens rect-1')) (wtt/token-identifier token-target'))))
(t/testing "shapes width and height got updated"
(t/is (= (:width rect-1') 100))
(t/is (= (:height rect-1') 100))))))))))
(t/deftest test-apply-opacity
(t/testing "applies opacity token and updates the shapes opacity"