0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-08 08:09:14 -05:00

Restore all logic tests

This commit is contained in:
Florian Schroedl 2024-10-02 17:10:07 +02:00
parent 1097c1f282
commit 921f4a6660

View file

@ -136,261 +136,302 @@
(t/testing "while :r4 was kept with borderRadius.sm" (t/testing "while :r4 was kept with borderRadius.sm"
(t/is (= (:r4 (:applied-tokens rect-1')) (:name token-sm))))))))))) (t/is (= (:r4 (:applied-tokens rect-1')) (:name token-sm)))))))))))
;; (t/deftest test-apply-dimensions (t/deftest test-apply-dimensions
;; (t/testing "applies dimensions token and updates the shapes width and height" (t/testing "applies dimensions token and updates the shapes width and height"
;; (t/async (t/async
;; done done
;; (let [file (-> (setup-file-with-tokens) (let [file (-> (setup-file-with-tokens)
;; (toht/add-token :token-target {:value "100" (toht/add-token :token-target {:value "100"
;; :name "dimensions.sm" :name "dimensions.sm"
;; :type :dimensions})) :type :dimensions}))
;; store (ths/setup-store file) store (ths/setup-store file)
;; rect-1 (cths/get-shape file :rect-1) rect-1 (cths/get-shape file :rect-1)
;; events [(wtch/apply-token {:shape-ids [(:id rect-1)] events [(wtch/apply-token {:shape-ids [(:id rect-1)]
;; :attributes #{:width :height} :attributes #{:width :height}
;; :token (toht/get-token file :token-target) :token (toht/get-token file :token-target)
;; :on-update-shape wtch/update-shape-dimensions})]] :on-update-shape wtch/update-shape-dimensions})]]
;; (tohs/run-store-async (tohs/run-store-async
;; store done events store done events
;; (fn [new-state] (fn [new-state]
;; (let [file' (ths/get-file-from-store new-state) (let [file' (ths/get-file-from-store new-state)
;; token-target' (toht/get-token file' :token-target) token-target' (toht/get-token file' :token-target)
;; rect-1' (cths/get-shape file' :rect-1)] rect-1' (cths/get-shape file' :rect-1)]
;; (t/testing "shape `:applied-tokens` got updated" (t/testing "shape `:applied-tokens` got updated"
;; (t/is (some? (:applied-tokens rect-1'))) (t/is (some? (:applied-tokens rect-1')))
;; (t/is (= (:width (:applied-tokens rect-1')) (wtt/token-identifier token-target'))) (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/is (= (:height (:applied-tokens rect-1')) (wtt/token-identifier token-target'))))
;; (t/testing "shapes width and height got updated" (t/testing "shapes width and height got updated"
;; (t/is (= (:width rect-1') 100)) (t/is (= (:width rect-1') 100))
;; (t/is (= (:height rect-1') 100)))))))))) (t/is (= (:height rect-1') 100))))))))))
;; (t/deftest test-apply-sizing (t/deftest test-apply-dimensions
;; (t/testing "applies sizing token and updates the shapes width and height" (t/testing "applies dimensions token and updates the shapes width and height"
;; (t/async (t/async
;; done done
;; (let [file (-> (setup-file-with-tokens) (let [dimensions-token {:name "dimensions.sm"
;; (toht/add-token :token-target {:value "100" :value "100"
;; :name "sizing.sm" :type :dimensions}
;; :type :sizing})) file (-> (setup-file-with-tokens)
;; store (ths/setup-store file) (update-in [:data :tokens-lib]
;; rect-1 (cths/get-shape file :rect-1) #(ctob/add-token-in-set % "Set A" (ctob/make-token dimensions-token))))
;; events [(wtch/apply-token {:shape-ids [(:id rect-1)] store (ths/setup-store file)
;; :attributes #{:width :height} rect-1 (cths/get-shape file :rect-1)
;; :token (toht/get-token file :token-target) events [(wtch/apply-token {:shape-ids [(:id rect-1)]
;; :on-update-shape wtch/update-shape-dimensions})]] :attributes #{:width :height}
;; (tohs/run-store-async :token (toht/get-token file "dimensions.sm")
;; store done events :on-update-shape wtch/update-shape-dimensions})]]
;; (fn [new-state] (tohs/run-store-async
;; (let [file' (ths/get-file-from-store new-state) store done events
;; token-target' (toht/get-token file' :token-target) (fn [new-state]
;; rect-1' (cths/get-shape file' :rect-1)] (let [file' (ths/get-file-from-store new-state)
;; (t/testing "shape `:applied-tokens` got updated" token-target' (toht/get-token file' "dimensions.sm")
;; (t/is (some? (:applied-tokens rect-1'))) rect-1' (cths/get-shape file' :rect-1)]
;; (t/is (= (:width (:applied-tokens rect-1')) (wtt/token-identifier token-target'))) (t/testing "shape `:applied-tokens` got updated"
;; (t/is (= (:height (:applied-tokens rect-1')) (wtt/token-identifier token-target')))) (t/is (some? (:applied-tokens rect-1')))
;; (t/testing "shapes width and height got updated" (t/is (= (:width (:applied-tokens rect-1')) (:name token-target')))
;; (t/is (= (:width rect-1') 100)) (t/is (= (:height (:applied-tokens rect-1')) (:name token-target'))))
;; (t/is (= (:height rect-1') 100)))))))))) (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/deftest test-apply-sizing
;; (t/testing "applies opacity token and updates the shapes opacity" (t/testing "applies sizing token and updates the shapes width and height"
;; (t/async (t/async
;; done done
;; (let [file (-> (setup-file-with-tokens) (let [sizing-token {:name "sizing.sm"
;; (toht/add-token :opacity-float {:value "0.3" :value "100"
;; :name "opacity.float" :type :sizing}
;; :type :opacity}) file (-> (setup-file-with-tokens)
;; (toht/add-token :opacity-percent {:value "40%" (update-in [:data :tokens-lib]
;; :name "opacity.percent" #(ctob/add-token-in-set % "Set A" (ctob/make-token sizing-token))))
;; :type :opacity}) store (ths/setup-store file)
;; (toht/add-token :opacity-invalid {:value "100" rect-1 (cths/get-shape file :rect-1)
;; :name "opacity.invalid" events [(wtch/apply-token {:shape-ids [(:id rect-1)]
;; :type :opacity})) :attributes #{:width :height}
;; store (ths/setup-store file) :token (toht/get-token file "sizing.sm")
;; rect-1 (cths/get-shape file :rect-1) :on-update-shape wtch/update-shape-dimensions})]]
;; rect-2 (cths/get-shape file :rect-2) (tohs/run-store-async
;; rect-3 (cths/get-shape file :rect-3) store done events
;; events [(wtch/apply-token {:shape-ids [(:id rect-1)] (fn [new-state]
;; :attributes #{:opacity} (let [file' (ths/get-file-from-store new-state)
;; :token (toht/get-token file :opacity-float) token-target' (toht/get-token file' "sizing.sm")
;; :on-update-shape wtch/update-opacity}) rect-1' (cths/get-shape file' :rect-1)]
;; (wtch/apply-token {:shape-ids [(:id rect-2)] (t/testing "shape `:applied-tokens` got updated"
;; :attributes #{:opacity} (t/is (some? (:applied-tokens rect-1')))
;; :token (toht/get-token file :opacity-percent) (t/is (= (:width (:applied-tokens rect-1')) (:name token-target')))
;; :on-update-shape wtch/update-opacity}) (t/is (= (:height (:applied-tokens rect-1')) (:name token-target'))))
;; (wtch/apply-token {:shape-ids [(:id rect-3)] (t/testing "shapes width and height got updated"
;; :attributes #{:opacity} (t/is (= (:width rect-1') 100))
;; :token (toht/get-token file :opacity-invalid) (t/is (= (:height rect-1') 100))))))))))
;; :on-update-shape wtch/update-opacity})]]
;; (tohs/run-store-async
;; store done events
;; (fn [new-state]
;; (let [file' (ths/get-file-from-store new-state)
;; rect-1' (cths/get-shape file' :rect-1)
;; rect-2' (cths/get-shape file' :rect-2)
;; rect-3' (cths/get-shape file' :rect-3)
;; token-opacity-float (toht/get-token file' :opacity-float)
;; token-opacity-percent (toht/get-token file' :opacity-percent)
;; token-opacity-invalid (toht/get-token file' :opacity-invalid)]
;; (t/testing "float value got translated to float and applied to opacity"
;; (t/is (= (:opacity (:applied-tokens rect-1')) (wtt/token-identifier token-opacity-float)))
;; (t/is (= (:opacity rect-1') 0.3)))
;; (t/testing "percentage value got translated to float and applied to opacity"
;; (t/is (= (:opacity (:applied-tokens rect-2')) (wtt/token-identifier token-opacity-percent)))
;; (t/is (= (:opacity rect-2') 0.4)))
;; (t/testing "invalid opacity value got applied but did not change shape"
;; (t/is (= (:opacity (:applied-tokens rect-3')) (wtt/token-identifier token-opacity-invalid)))
;; (t/is (nil? (:opacity rect-3')))))))))))
;; (t/deftest test-apply-rotation (t/deftest test-apply-opacity
;; (t/testing "applies rotation token and updates the shapes rotation" (t/testing "applies opacity token and updates the shapes opacity"
;; (t/async (t/async
;; done done
;; (let [file (-> (setup-file-with-tokens) (let [opacity-float {:name "opacity.float"
;; (toht/add-token :token-target {:value "120" :value "0.3"
;; :name "rotation.medium" :type :opacity}
;; :type :rotation})) opacity-percent {:name "opacity.percent"
;; store (ths/setup-store file) :value "40%"
;; rect-1 (cths/get-shape file :rect-1) :type :opacity}
;; events [(wtch/apply-token {:shape-ids [(:id rect-1)] opacity-invalid {:name "opacity.invalid"
;; :attributes #{:rotation} :value "100"
;; :token (toht/get-token file :token-target) :type :opacity}
;; :on-update-shape wtch/update-rotation})]] file (-> (setup-file-with-tokens)
;; (tohs/run-store-async (update-in [:data :tokens-lib]
;; store done events #(-> %
;; (fn [new-state] (ctob/add-token-in-set "Set A" (ctob/make-token opacity-float))
;; (let [file' (ths/get-file-from-store new-state) (ctob/add-token-in-set "Set A" (ctob/make-token opacity-percent))
;; token-target' (toht/get-token file' :token-target) (ctob/add-token-in-set "Set A" (ctob/make-token opacity-invalid)))))
;; rect-1' (cths/get-shape file' :rect-1)] store (ths/setup-store file)
;; (t/is (some? (:applied-tokens rect-1'))) rect-1 (cths/get-shape file :rect-1)
;; (t/is (= (:rotation (:applied-tokens rect-1')) (wtt/token-identifier token-target'))) rect-2 (cths/get-shape file :rect-2)
;; (t/is (= (:rotation rect-1') 120))))))))) rect-3 (cths/get-shape file :rect-3)
events [(wtch/apply-token {:shape-ids [(:id rect-1)]
:attributes #{:opacity}
:token (toht/get-token file "opacity.float")
:on-update-shape wtch/update-opacity})
(wtch/apply-token {:shape-ids [(:id rect-2)]
:attributes #{:opacity}
:token (toht/get-token file "opacity.percent")
:on-update-shape wtch/update-opacity})
(wtch/apply-token {:shape-ids [(:id rect-3)]
:attributes #{:opacity}
:token (toht/get-token file "opacity.invalid")
:on-update-shape wtch/update-opacity})]]
(tohs/run-store-async
store done events
(fn [new-state]
(let [file' (ths/get-file-from-store new-state)
rect-1' (cths/get-shape file' :rect-1)
rect-2' (cths/get-shape file' :rect-2)
rect-3' (cths/get-shape file' :rect-3)
token-opacity-float (toht/get-token file' "opacity.float")
token-opacity-percent (toht/get-token file' "opacity.percent")
token-opacity-invalid (toht/get-token file' "opacity.invalid")]
(t/testing "float value got translated to float and applied to opacity"
(t/is (= (:opacity (:applied-tokens rect-1')) (:name token-opacity-float)))
(t/is (= (:opacity rect-1') 0.3)))
(t/testing "percentage value got translated to float and applied to opacity"
(t/is (= (:opacity (:applied-tokens rect-2')) (:name token-opacity-percent)))
(t/is (= (:opacity rect-2') 0.4)))
(t/testing "invalid opacity value got applied but did not change shape"
(t/is (= (:opacity (:applied-tokens rect-3')) (:name token-opacity-invalid)))
(t/is (nil? (:opacity rect-3')))))))))))
;; (t/deftest test-apply-stroke-width (t/deftest test-apply-rotation
;; (t/testing "applies stroke-width token and updates the shapes with stroke" (t/testing "applies rotation token and updates the shapes rotation"
;; (t/async (t/async
;; done done
;; (let [file (-> (setup-file-with-tokens {:rect-1 {:strokes [{:stroke-alignment :inner, (let [rotation-token {:name "rotation.medium"
;; :stroke-style :solid, :value "120"
;; :stroke-color "#000000", :type :rotation}
;; :stroke-opacity 1, file (-> (setup-file-with-tokens)
;; :stroke-width 5}]}}) (update-in [:data :tokens-lib]
;; (toht/add-token :token-target {:value "10" #(ctob/add-token-in-set % "Set A" (ctob/make-token rotation-token))))
;; :name "stroke-width.sm" store (ths/setup-store file)
;; :type :stroke-width})) rect-1 (cths/get-shape file :rect-1)
;; store (ths/setup-store file) events [(wtch/apply-token {:shape-ids [(:id rect-1)]
;; rect-with-stroke (cths/get-shape file :rect-1) :attributes #{:rotation}
;; rect-without-stroke (cths/get-shape file :rect-2) :token (toht/get-token file "rotation.medium")
;; events [(wtch/apply-token {:shape-ids [(:id rect-with-stroke) (:id rect-without-stroke)] :on-update-shape wtch/update-rotation})]]
;; :attributes #{:stroke-width} (tohs/run-store-async
;; :token (toht/get-token file :token-target) store done events
;; :on-update-shape wtch/update-stroke-width})]] (fn [new-state]
;; (tohs/run-store-async (let [file' (ths/get-file-from-store new-state)
;; store done events token-target' (toht/get-token file' "rotation.medium")
;; (fn [new-state] rect-1' (cths/get-shape file' :rect-1)]
;; (let [file' (ths/get-file-from-store new-state) (t/is (some? (:applied-tokens rect-1')))
;; token-target' (toht/get-token file' :token-target) (t/is (= (:rotation (:applied-tokens rect-1')) (:name token-target')))
;; rect-with-stroke' (cths/get-shape file' :rect-1) (t/is (= (:rotation rect-1') 120)))))))))
;; 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')) (wtt/token-identifier 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')) (wtt/token-identifier token-target')))
;; (t/is (empty? (:strokes rect-without-stroke')))))))))))
;; (t/deftest test-toggle-token-none (t/deftest test-apply-stroke-width
;; (t/testing "should apply token to all selected items, where no item has the token applied" (t/testing "applies stroke-width token and updates the shapes with stroke"
;; (t/async (t/async
;; done done
;; (let [file (setup-file-with-tokens) (let [stroke-width-token {:name "stroke-width.sm"
;; store (ths/setup-store file) :value "10"
;; rect-1 (cths/get-shape file :rect-1) :type :stroke-width}
;; rect-2 (cths/get-shape file :rect-2) file (-> (setup-file-with-tokens {:rect-1 {:strokes [{:stroke-alignment :inner,
;; events [(wtch/toggle-token {:shapes [rect-1 rect-2] :stroke-style :solid,
;; :token-type-props {:attributes #{:rx :ry} :stroke-color "#000000",
;; :on-update-shape wtch/update-shape-radius-all} :stroke-opacity 1,
;; :token (toht/get-token file :token-2)})]] :stroke-width 5}]}})
;; (tohs/run-store-async (update-in [:data :tokens-lib]
;; store done events #(ctob/add-token-in-set % "Set A" (ctob/make-token stroke-width-token))))
;; (fn [new-state] store (ths/setup-store file)
;; (let [file' (ths/get-file-from-store new-state) rect-with-stroke (cths/get-shape file :rect-1)
;; token-2' (toht/get-token file' :token-2) rect-without-stroke (cths/get-shape file :rect-2)
;; rect-1' (cths/get-shape file' :rect-1) events [(wtch/apply-token {:shape-ids [(:id rect-with-stroke) (:id rect-without-stroke)]
;; rect-2' (cths/get-shape file' :rect-2)] :attributes #{:stroke-width}
;; (t/is (some? (:applied-tokens rect-1'))) :token (toht/get-token file "stroke-width.sm")
;; (t/is (some? (:applied-tokens rect-2'))) :on-update-shape wtch/update-stroke-width})]]
;; (t/is (= (:rx (:applied-tokens rect-1')) (wtt/token-identifier token-2'))) (tohs/run-store-async
;; (t/is (= (:rx (:applied-tokens rect-2')) (wtt/token-identifier token-2'))) store done events
;; (t/is (= (:ry (:applied-tokens rect-1')) (wtt/token-identifier token-2'))) (fn [new-state]
;; (t/is (= (:ry (:applied-tokens rect-2')) (wtt/token-identifier token-2'))) (let [file' (ths/get-file-from-store new-state)
;; (t/is (= (:rx rect-1') 24)) token-target' (toht/get-token file' "stroke-width.sm")
;; (t/is (= (:rx rect-2') 24))))))))) 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')) (:name 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')) (:name token-target')))
(t/is (empty? (:strokes rect-without-stroke')))))))))))
;; (t/deftest test-toggle-token-mixed (t/deftest test-toggle-token-none
;; (t/testing "should unapply given token if one of the selected items has the token applied while keeping other tokens with some attributes" (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-with-tokens) (let [file (setup-file-with-tokens)
;; (toht/apply-token-to-shape :rect-1 :token-1 #{:rx :ry}) store (ths/setup-store file)
;; (toht/apply-token-to-shape :rect-3 :token-2 #{:rx :ry})) rect-1 (cths/get-shape file :rect-1)
;; store (ths/setup-store file) rect-2 (cths/get-shape file :rect-2)
events [(wtch/toggle-token {:shapes [rect-1 rect-2]
:token-type-props {:attributes #{:rx :ry}
:on-update-shape wtch/update-shape-radius-all}
:token (toht/get-token file "borderRadius.md")})]]
(tohs/run-store-async
store done events
(fn [new-state]
(let [file' (ths/get-file-from-store new-state)
token-2' (toht/get-token file' "borderRadius.md")
rect-1' (cths/get-shape file' :rect-1)
rect-2' (cths/get-shape file' :rect-2)]
(t/is (some? (:applied-tokens rect-1')))
(t/is (some? (:applied-tokens rect-2')))
(t/is (= (:rx (:applied-tokens rect-1')) (:name token-2')))
(t/is (= (:rx (:applied-tokens rect-2')) (:name token-2')))
(t/is (= (:ry (:applied-tokens rect-1')) (:name token-2')))
(t/is (= (:ry (:applied-tokens rect-2')) (:name token-2')))
(t/is (= (:rx rect-1') 24))
(t/is (= (:rx rect-2') 24)))))))))
;; rect-with-token (cths/get-shape file :rect-1) (t/deftest test-toggle-token-mixed
;; rect-without-token (cths/get-shape file :rect-2) (t/testing "should unapply given token if one of the selected items has the token applied while keeping other tokens with some attributes"
;; rect-with-other-token (cths/get-shape file :rect-3) (t/async
done
(let [file (-> (setup-file-with-tokens)
(toht/apply-token-to-shape :rect-1 "borderRadius.sm" #{:rx :ry})
(toht/apply-token-to-shape :rect-3 "borderRadius.md" #{:rx :ry}))
store (ths/setup-store file)
;; events [(wtch/toggle-token {:shapes [rect-with-token rect-without-token rect-with-other-token] rect-with-token (cths/get-shape file :rect-1)
;; :token (toht/get-token file :token-1) rect-without-token (cths/get-shape file :rect-2)
;; :token-type-props {:attributes #{:rx :ry}}})]] rect-with-other-token (cths/get-shape file :rect-3)
;; (tohs/run-store-async
;; store done events
;; (fn [new-state]
;; (let [file' (ths/get-file-from-store new-state)
;; rect-with-token' (cths/get-shape file' :rect-1)
;; rect-without-token' (cths/get-shape file' :rect-2)
;; rect-with-other-token' (cths/get-shape file' :rect-3)]
;; (t/testing "rect-with-token got the token remove" events [(wtch/toggle-token {:shapes [rect-with-token rect-without-token rect-with-other-token]
;; (t/is (nil? (:rx (:applied-tokens rect-with-token')))) :token (toht/get-token file "borderRadius.sm")
;; (t/is (nil? (:ry (:applied-tokens rect-with-token'))))) :token-type-props {:attributes #{:rx :ry}}})]]
(tohs/run-store-async
store done events
(fn [new-state]
(let [file' (ths/get-file-from-store new-state)
rect-with-token' (cths/get-shape file' :rect-1)
rect-without-token' (cths/get-shape file' :rect-2)
rect-with-other-token' (cths/get-shape file' :rect-3)]
;; (t/testing "rect-without-token didn't get updated" (t/testing "rect-with-token got the token removed"
;; (t/is (= (:applied-tokens rect-without-token') (:applied-tokens rect-without-token)))) (t/is (nil? (:rx (:applied-tokens rect-with-token'))))
(t/is (nil? (:ry (:applied-tokens rect-with-token')))))
;; (t/testing "rect-with-other-token didn't get updated" (t/testing "rect-without-token didn't get updated"
;; (t/is (= (:applied-tokens rect-with-other-token') (:applied-tokens rect-with-other-token))))))))))) (t/is (= (:applied-tokens rect-without-token') (:applied-tokens rect-without-token))))
;; (t/deftest test-toggle-token-apply-to-all (t/testing "rect-with-other-token didn't get updated"
;; (t/testing "should apply token to all if none of the shapes has it applied" (t/is (= (:applied-tokens rect-with-other-token') (:applied-tokens rect-with-other-token)))))))))))
;; (t/async
;; done
;; (let [file (-> (setup-file-with-tokens)
;; (toht/apply-token-to-shape :rect-1 :token-2 #{:rx :ry})
;; (toht/apply-token-to-shape :rect-3 :token-2 #{:rx :ry}))
;; store (ths/setup-store file)
;; rect-with-other-token-1 (cths/get-shape file :rect-1) (t/deftest test-toggle-token-apply-to-all
;; rect-without-token (cths/get-shape file :rect-2) (t/testing "should apply token to all if none of the shapes has it applied"
;; rect-with-other-token-2 (cths/get-shape file :rect-3) (t/async
done
(let [file (-> (setup-file-with-tokens)
(toht/apply-token-to-shape :rect-1 "borderRadius.md" #{:rx :ry})
(toht/apply-token-to-shape :rect-3 "borderRadius.md" #{:rx :ry}))
store (ths/setup-store file)
;; events [(wtch/toggle-token {:shapes [rect-with-other-token-1 rect-without-token rect-with-other-token-2] rect-with-other-token-1 (cths/get-shape file :rect-1)
;; :token (toht/get-token file :token-1) rect-without-token (cths/get-shape file :rect-2)
;; :token-type-props {:attributes #{:rx :ry}}})]] rect-with-other-token-2 (cths/get-shape file :rect-3)
;; (tohs/run-store-async
;; store done events
;; (fn [new-state]
;; (let [file' (ths/get-file-from-store new-state)
;; target-token (toht/get-token file' :token-1)
;; rect-with-other-token-1' (cths/get-shape file' :rect-1)
;; rect-without-token' (cths/get-shape file' :rect-2)
;; rect-with-other-token-2' (cths/get-shape file' :rect-3)]
;; (t/testing "token got applied to all shapes" events [(wtch/toggle-token {:shapes [rect-with-other-token-1 rect-without-token rect-with-other-token-2]
;; (t/is (= (:rx (:applied-tokens rect-with-other-token-1')) (wtt/token-identifier target-token))) :token (toht/get-token file "borderRadius.sm")
;; (t/is (= (:rx (:applied-tokens rect-without-token')) (wtt/token-identifier target-token))) :token-type-props {:attributes #{:rx :ry}}})]]
;; (t/is (= (:rx (:applied-tokens rect-with-other-token-2')) (wtt/token-identifier target-token))) (tohs/run-store-async
store done events
(fn [new-state]
(let [file' (ths/get-file-from-store new-state)
target-token (toht/get-token file' "borderRadius.sm")
rect-with-other-token-1' (cths/get-shape file' :rect-1)
rect-without-token' (cths/get-shape file' :rect-2)
rect-with-other-token-2' (cths/get-shape file' :rect-3)]
;; (t/is (= (:ry (:applied-tokens rect-with-other-token-1')) (wtt/token-identifier target-token))) (t/testing "token got applied to all shapes"
;; (t/is (= (:ry (:applied-tokens rect-without-token')) (wtt/token-identifier target-token))) (t/is (= (:rx (:applied-tokens rect-with-other-token-1')) (:name target-token)))
;; (t/is (= (:ry (:applied-tokens rect-with-other-token-2')) (wtt/token-identifier target-token))))))))))) (t/is (= (:rx (:applied-tokens rect-without-token')) (:name target-token)))
(t/is (= (:rx (:applied-tokens rect-with-other-token-2')) (:name target-token)))
(t/is (= (:ry (:applied-tokens rect-with-other-token-1')) (:name target-token)))
(t/is (= (:ry (:applied-tokens rect-without-token')) (:name target-token)))
(t/is (= (:ry (:applied-tokens rect-with-other-token-2')) (:name target-token)))))))))))