mirror of
https://github.com/penpot/penpot.git
synced 2025-01-21 06:02:32 -05:00
Move to tests
This commit is contained in:
parent
111900c122
commit
28f25da9e8
2 changed files with 8 additions and 14 deletions
|
@ -30,20 +30,9 @@
|
|||
(map second)
|
||||
(into #{})))
|
||||
|
||||
(defn token-self-reference? [token-name reference-string]
|
||||
(let [escaped-name (str/replace token-name "." "\\.")
|
||||
regex (-> (str "{" escaped-name "}")
|
||||
(re-pattern))]
|
||||
(re-find regex reference-string)))
|
||||
|
||||
(comment
|
||||
(token-self-reference? {:name "some.value"} "{md} + {some.value}")
|
||||
(token-self-reference? {:name "some.value"} "some.value")
|
||||
(token-self-reference? {:name "some.value"} "{some|value}")
|
||||
(token-self-reference? {:name "sm"} "{md} + {lg}")
|
||||
(token-self-reference? {:name "sm"} "1")
|
||||
(token-self-reference? {:name ""} "121")
|
||||
nil)
|
||||
(defn token-self-reference? [token-name value-string]
|
||||
(let [refs (find-token-references value-string)]
|
||||
(get refs token-name)))
|
||||
|
||||
(defn tokens->style-dictionary+
|
||||
"Resolves references and math expressions using StyleDictionary.
|
||||
|
|
|
@ -18,3 +18,8 @@
|
|||
(t/is (nil? (wtsd/find-token-references "1 + 2")))
|
||||
;; Edge-case: Ignore unmatched closing parens
|
||||
(t/is (= #{"foo" "bar"} (wtsd/find-token-references "{foo}} + {bar}"))))
|
||||
|
||||
(t/deftest test-token-self-reference?
|
||||
(t/is (some? (wtsd/token-self-reference? "some.value" "{md} + {some.value}")))
|
||||
(t/is (nil? (wtsd/token-self-reference? "some.value" "some.value")))
|
||||
(t/is (nil? (wtsd/token-self-reference? "sm" "{md} + {lg}"))))
|
||||
|
|
Loading…
Add table
Reference in a new issue