mirror of
https://github.com/penpot/penpot.git
synced 2025-08-03 17:28:24 +02:00
✨ Fix single set import
This commit is contained in:
parent
982118c942
commit
a20dd3f955
6 changed files with 127 additions and 50 deletions
|
@ -0,0 +1,6 @@
|
|||
{"color":
|
||||
{"red":
|
||||
{"100":
|
||||
{"value":"red",
|
||||
"type":"color",
|
||||
"description":""}}}}
|
6
common/test/common_tests/types/data/single-set.json
Normal file
6
common/test/common_tests/types/data/single-set.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{"color":
|
||||
{"red":
|
||||
{"100":
|
||||
{"$value":"red",
|
||||
"$type":"color",
|
||||
"$description":""}}}}
|
|
@ -1371,6 +1371,30 @@
|
|||
(t/testing "invalid tokens got discarded"
|
||||
(t/is (nil? (get-set-token "typography" "H1.Bold")))))))
|
||||
|
||||
#?(:clj
|
||||
(t/deftest single-set-legacy-json-decoding
|
||||
(let [json (-> (slurp "test/common_tests/types/data/legacy-single-set.json")
|
||||
(tr/decode-str))
|
||||
lib (ctob/decode-single-set-legacy-json (ctob/ensure-tokens-lib nil) "single_set" json)
|
||||
get-set-token (fn [set-name token-name]
|
||||
(some-> (ctob/get-set lib set-name)
|
||||
(ctob/get-token token-name)))]
|
||||
(t/is (= '("single_set") (ctob/get-ordered-set-names lib)))
|
||||
(t/testing "token added"
|
||||
(t/is (some? (get-set-token "single_set" "color.red.100")))))))
|
||||
|
||||
#?(:clj
|
||||
(t/deftest single-set-dtcg-json-decoding
|
||||
(let [json (-> (slurp "test/common_tests/types/data/single-set.json")
|
||||
(tr/decode-str))
|
||||
lib (ctob/decode-single-set-json (ctob/ensure-tokens-lib nil) "single_set" json)
|
||||
get-set-token (fn [set-name token-name]
|
||||
(some-> (ctob/get-set lib set-name)
|
||||
(ctob/get-token token-name)))]
|
||||
(t/is (= '("single_set") (ctob/get-ordered-set-names lib)))
|
||||
(t/testing "token added"
|
||||
(t/is (some? (get-set-token "single_set" "color.red.100")))))))
|
||||
|
||||
#?(:clj
|
||||
(t/deftest dtcg-encoding-decoding-json
|
||||
(let [json (-> (slurp "test/common_tests/types/data/tokens-multi-set-example.json")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue