mirror of
https://github.com/penpot/penpot.git
synced 2025-01-06 14:50:20 -05:00
Migrate token tests to tokens-lib
This commit is contained in:
parent
bca4ea3819
commit
3681678dc4
2 changed files with 26 additions and 24 deletions
|
@ -1,16 +1,18 @@
|
|||
(ns token-tests.helpers.tokens
|
||||
(:require
|
||||
[app.common.test-helpers.ids-map :as thi]
|
||||
[app.main.ui.workspace.tokens.token :as wtt]))
|
||||
[app.main.ui.workspace.tokens.token :as wtt]
|
||||
[app.common.types.tokens-lib :as ctob]))
|
||||
|
||||
(defn add-token [state label params]
|
||||
(let [id (thi/new-id! label)
|
||||
token (assoc params :id id)]
|
||||
(update-in state [:data :tokens] assoc id token)))
|
||||
|
||||
(defn get-token [file label]
|
||||
(let [id (thi/id label)]
|
||||
(get-in file [:data :tokens id])))
|
||||
(defn get-token [file name]
|
||||
(some-> (get-in file [:data :tokens-li])
|
||||
(ctob/get-active-themes-set-tokens)
|
||||
(get name)))
|
||||
|
||||
(defn apply-token-to-shape [file shape-label token-label attributes]
|
||||
(let [first-page-id (get-in file [:data :pages 0])
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
(ns token-tests.logic.token-actions-test
|
||||
(:require
|
||||
[app.common.pprint :refer [pprint]]
|
||||
[token-tests.helpers.state :as tohs]
|
||||
[app.common.logging :as log]
|
||||
[app.common.test-helpers.compositions :as ctho]
|
||||
[app.common.test-helpers.files :as cthf]
|
||||
[app.common.test-helpers.shapes :as cths]
|
||||
[app.main.data.tokens :as wdt]
|
||||
[app.main.ui.workspace.tokens.changes :as wtch]
|
||||
[app.main.ui.workspace.tokens.token :as wtt]
|
||||
[app.main.ui.workspace.tokens.token-set :as wtts]
|
||||
[app.common.test-helpers.files :as cthf]
|
||||
[app.common.types.tokens-lib :as ctob]
|
||||
[cljs.test :as t :include-macros true]
|
||||
[frontend-tests.helpers.pages :as thp]
|
||||
[app.common.test-helpers.shapes :as cths]
|
||||
[frontend-tests.helpers.state :as ths]
|
||||
[token-tests.helpers.state :as tohs]
|
||||
[frontend-tests.helpers.pages :as thp]
|
||||
[token-tests.helpers.tokens :as toht]))
|
||||
|
||||
|
||||
|
@ -26,23 +23,26 @@
|
|||
(cthf/sample-file :file-1 :page-label :page-1))
|
||||
|
||||
(def border-radius-token
|
||||
{:value "12"
|
||||
:name "borderRadius.sm"
|
||||
{:name "borderRadius.sm"
|
||||
:value "12"
|
||||
:type :border-radius})
|
||||
|
||||
(def reference-border-radius-token
|
||||
{:value "{borderRadius.sm} * 2"
|
||||
:name "borderRadius.md"
|
||||
{:name "borderRadius.md"
|
||||
:value "{borderRadius.sm} * 2"
|
||||
:type :border-radius})
|
||||
|
||||
;; (defn setup-file-with-tokens
|
||||
;; [& {:keys [rect-1 rect-2 rect-3]}]
|
||||
;; (-> (setup-file)
|
||||
;; (ctho/add-rect :rect-1 rect-1)
|
||||
;; (ctho/add-rect :rect-2 rect-2)
|
||||
;; (ctho/add-rect :rect-3 rect-3)
|
||||
;; (toht/add-token :token-1 border-radius-token)
|
||||
;; (toht/add-token :token-2 reference-border-radius-token)))
|
||||
(defn setup-file-with-tokens
|
||||
[& {:keys [rect-1 rect-2 rect-3]}]
|
||||
(-> (setup-file)
|
||||
(ctho/add-rect :rect-1 rect-1)
|
||||
(ctho/add-rect :rect-2 rect-2)
|
||||
(ctho/add-rect :rect-3 rect-3)
|
||||
(assoc-in [:data :tokens-lib]
|
||||
(-> (ctob/make-tokens-lib)
|
||||
(ctob/add-set (ctob/make-token-set :name "Set A"))
|
||||
(ctob/add-token-in-set "Set A" (ctob/make-token border-radius-token))
|
||||
(ctob/add-token-in-set "Set A" (ctob/make-token reference-border-radius-token))))))
|
||||
|
||||
;; (t/deftest test-apply-token
|
||||
;; (t/testing "applies token to shape and updates shape attributes to resolved value"
|
||||
|
|
Loading…
Reference in a new issue