Validate if token values are too large

This commit is contained in:
Andrés Moya 2025-03-10 10:57:04 +01:00 committed by Andrés Moya
parent ba768f8744
commit e5bccc470b
5 changed files with 47 additions and 11 deletions

View file

@ -19,6 +19,15 @@
(ctob/add-token-in-set "core" (ctob/make-token {:value "{borderRadius.sm} * 2"
:name "borderRadius.md-with-dashes"
:type :border-radius}))
(ctob/add-token-in-set "core" (ctob/make-token {:name "borderRadius.large"
:value "123456789012345"
:type :border-radius}))
(ctob/add-token-in-set "core" (ctob/make-token {:name "borderRadius.largePx"
:value "123456789012345px"
:type :border-radius}))
(ctob/add-token-in-set "core" (ctob/make-token {:name "borderRadius.largeFn"
:value "{borderRadius.sm} * 200000000"
:type :border-radius}))
(ctob/get-all-tokens))]
(-> (sd/resolve-tokens+ tokens)
(p/finally
@ -27,6 +36,15 @@
(t/is (= "px" (get-in resolved-tokens ["borderRadius.sm" :unit])))
(t/is (= 24 (get-in resolved-tokens ["borderRadius.md-with-dashes" :resolved-value])))
(t/is (= "px" (get-in resolved-tokens ["borderRadius.md-with-dashes" :unit])))
(t/is (nil? (get-in resolved-tokens ["borderRadius.large" :resolved-value])))
(t/is (= :error.token/number-too-large
(get-in resolved-tokens ["borderRadius.large" :errors 0 :error/code])))
(t/is (nil? (get-in resolved-tokens ["borderRadius.largePx" :resolved-value])))
(t/is (= :error.token/number-too-large
(get-in resolved-tokens ["borderRadius.largePx" :errors 0 :error/code])))
(t/is (nil? (get-in resolved-tokens ["borderRadius.largeFn" :resolved-value])))
(t/is (= :error.token/number-too-large
(get-in resolved-tokens ["borderRadius.largeFn" :errors 0 :error/code])))
(done))))))))
(t/deftest process-json-stream-test