0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-23 15:26:29 -05:00

📎 Add decode test

This commit is contained in:
Eva Marco 2025-02-21 15:04:34 +01:00
parent cf70c09256
commit 108e137a46
2 changed files with 29 additions and 1 deletions

View file

@ -0,0 +1,11 @@
{
"dark":
{"small":
{"$value": "8",
"$type":"borderRadius",
"$description":""}},
"$themes": [],
"$metadata":
{"tokenSetOrder": ["dark"],
"activeThemes": [],
"activeSets": ["dark"]}}

View file

@ -1210,6 +1210,23 @@
(t/testing "invalid tokens got discarded"
(t/is (nil? (get-set-token "typography" "H1.Bold"))))))
(t/testing "decode-dtcg-json-default-team"
(let [json (-> (slurp "test/common_tests/types/data/tokens-default-team-only.json")
(tr/decode-str))
lib (ctob/decode-dtcg-json (ctob/ensure-tokens-lib nil) json)
get-set-token (fn [set-name token-name]
(some-> (ctob/get-set lib set-name)
(ctob/get-token token-name)))
themes (ctob/get-themes lib)]
(t/is (= '("dark") (ctob/get-ordered-set-names lib)))
(t/testing "token exist in dark set"
(t/is (tht/token-data-eq? (get-set-token "dark" "small")
{:value "8"
:type "borderRadius"
:description ""})))
(t/testing "There is any theme"
(t/is (= themes [])))))
(t/testing "encode-dtcg-json"
(let [now (dt/now)
tokens-lib (-> (ctob/make-tokens-lib)
@ -1366,7 +1383,7 @@
"$description" ""}}}}}]
(t/is (= expected result))))
(t/testing "encode-dtcg-json-with-active-theme-and-set"
(let [now (dt/now)
tokens-lib (-> (ctob/make-tokens-lib)