From 1097c1f28254a2e0a7d0b7173fe9f625cb973f01 Mon Sep 17 00:00:00 2001 From: Florian Schroedl Date: Wed, 2 Oct 2024 17:02:10 +0200 Subject: [PATCH] Restore apply overwrite --- .../token_tests/logic/token_actions_test.cljs | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/frontend/test/token_tests/logic/token_actions_test.cljs b/frontend/test/token_tests/logic/token_actions_test.cljs index f0a89c13a..d69599732 100644 --- a/frontend/test/token_tests/logic/token_actions_test.cljs +++ b/frontend/test/token_tests/logic/token_actions_test.cljs @@ -102,39 +102,39 @@ (t/is (= (:rx rect-1') 24)) (t/is (= (:ry rect-1') 24)))))))))) -;; (t/deftest test-apply-token-overwrite -;; (t/testing "removes old token attributes and applies only single attribute" -;; (t/async -;; done -;; (let [file (setup-file-with-tokens) -;; store (ths/setup-store file) -;; rect-1 (cths/get-shape file :rect-1) -;; events [;; Apply `:token-1` to all border radius attributes -;; (wtch/apply-token {:attributes #{:rx :ry :r1 :r2 :r3 :r4} -;; :token (toht/get-token file :token-1) -;; :shape-ids [(:id rect-1)] -;; :on-update-shape wtch/update-shape-radius-all}) -;; ;; Apply single `:r1` attribute to same shape -;; ;; while removing other attributes from the border-radius set -;; ;; but keep `:r4` for testing purposes -;; (wtch/apply-token {:attributes #{:r1} -;; :attributes-to-remove #{:rx :ry :r1 :r2 :r3} -;; :token (toht/get-token file :token-2) -;; :shape-ids [(:id rect-1)] -;; :on-update-shape wtch/update-shape-radius-all})]] -;; (tohs/run-store-async -;; store done events -;; (fn [new-state] -;; (let [file' (ths/get-file-from-store new-state) -;; token-1' (toht/get-token file' :token-1) -;; token-2' (toht/get-token file' :token-2) -;; rect-1' (cths/get-shape file' :rect-1)] -;; (t/testing "other border-radius attributes got removed" -;; (t/is (nil? (:rx (:applied-tokens rect-1'))))) -;; (t/testing "r1 got applied with :token-2" -;; (t/is (= (:r1 (:applied-tokens rect-1')) (wtt/token-identifier token-2')))) -;; (t/testing "while :r4 was kept" -;; (t/is (= (:r4 (:applied-tokens rect-1')) (wtt/token-identifier token-1')))))))))));))))))))))) +(t/deftest test-apply-token-overwrite + (t/testing "removes old token attributes and applies only single attribute" + (t/async + done + (let [file (setup-file-with-tokens) + store (ths/setup-store file) + rect-1 (cths/get-shape file :rect-1) + events [;; Apply "borderRadius.sm" to all border radius attributes + (wtch/apply-token {:attributes #{:rx :ry :r1 :r2 :r3 :r4} + :token (toht/get-token file "borderRadius.sm") + :shape-ids [(:id rect-1)] + :on-update-shape wtch/update-shape-radius-all}) + ;; Apply single `:r1` attribute to same shape + ;; while removing other attributes from the border-radius set + ;; but keep `:r4` for testing purposes + (wtch/apply-token {:attributes #{:r1} + :attributes-to-remove #{:rx :ry :r1 :r2 :r3} + :token (toht/get-token file "borderRadius.md") + :shape-ids [(:id rect-1)] + :on-update-shape wtch/update-shape-radius-all})]] + (tohs/run-store-async + store done events + (fn [new-state] + (let [file' (ths/get-file-from-store new-state) + token-sm (toht/get-token file' "borderRadius.sm") + token-md (toht/get-token file' "borderRadius.md") + rect-1' (cths/get-shape file' :rect-1)] + (t/testing "other border-radius attributes got removed" + (t/is (nil? (:rx (:applied-tokens rect-1'))))) + (t/testing "r1 got applied with borderRadius.md" + (t/is (= (:r1 (:applied-tokens rect-1')) (:name token-md)))) + (t/testing "while :r4 was kept with borderRadius.sm" + (t/is (= (:r4 (:applied-tokens rect-1')) (:name token-sm))))))))))) ;; (t/deftest test-apply-dimensions ;; (t/testing "applies dimensions token and updates the shapes width and height"