💄 Minor changes

This commit is contained in:
Andrés Moya
2025-08-20 13:14:45 +02:00
committed by Andrés Moya
parent 021b8f81ca
commit 5f886e141a
7 changed files with 70 additions and 82 deletions

View File

@@ -405,24 +405,24 @@
[:type [:= :set-tokens-lib]] [:type [:= :set-tokens-lib]]
[:tokens-lib ::sm/any]]] [:tokens-lib ::sm/any]]]
[:set-token-set [:set-token-set
[:map {:title "SetTokenSetChange"} [:map {:title "SetTokenSetChange"}
[:type [:= :set-token-set]] [:type [:= :set-token-set]]
[:set-id ::sm/uuid] [:set-id ::sm/uuid]
[:group? :boolean] [:group? :boolean]
[:token-set [:maybe ctob/schema:token-set-attrs]]]] [:token-set [:maybe ctob/schema:token-set-attrs]]]]
[:set-token [:set-token
[:map {:title "SetTokenChange"} [:map {:title "SetTokenChange"}
[:type [:= :set-token]] [:type [:= :set-token]]
[:set-name :string] [:set-name :string]
[:token-id ::sm/uuid] [:token-id ::sm/uuid]
[:token [:maybe ctob/schema:token-attrs]]]] [:token [:maybe ctob/schema:token-attrs]]]]
[:set-base-font-size [:set-base-font-size
[:map {:title "ModBaseFontSize"} [:map {:title "ModBaseFontSize"}
[:type [:= :set-base-font-size]] [:type [:= :set-base-font-size]]
[:base-font-size :string]]]]) [:base-font-size :string]]]])
(def schema:changes (def schema:changes
[:sequential {:gen/max 5 :gen/min 1} schema:change]) [:sequential {:gen/max 5 :gen/min 1} schema:change])
@@ -982,7 +982,7 @@
(update data :tokens-lib (update data :tokens-lib
(fn [lib] (fn [lib]
(let [lib' (ctob/ensure-tokens-lib lib) (let [lib' (ctob/ensure-tokens-lib lib)
set (ctob/set-by-name lib' set-name)] ;; FIXME: remove this when set-token uses set-id set (ctob/get-set-by-name lib' set-name)] ;; FIXME: remove this when set-token uses set-id
(cond (cond
(not token) (not token)
(ctob/delete-token-from-set lib' set-name token-id) (ctob/delete-token-from-set lib' set-name token-id)
@@ -999,14 +999,14 @@
(update data :tokens-lib (update data :tokens-lib
(fn [lib] (fn [lib]
(let [lib' (ctob/ensure-tokens-lib lib) (let [lib' (ctob/ensure-tokens-lib lib)
set (ctob/set-by-id lib' set-id)] ;; FIXME: remove this when set-token-set uses set-id set (ctob/get-set lib' set-id)] ;; FIXME: remove this when set-token-set uses set-id
(cond (cond
(not token-set) (not token-set)
(if group? (if group?
(ctob/delete-set-group lib' (ctob/get-name set)) ;; FIXME: move to a separate change (ctob/delete-set-group lib' (ctob/get-name set)) ;; FIXME: move to a separate change
(ctob/delete-set lib' (ctob/get-name set))) (ctob/delete-set lib' (ctob/get-name set)))
(not (ctob/set-by-id lib' set-id)) (not (ctob/get-set lib' set-id))
(ctob/add-set lib' (ctob/make-token-set token-set)) (ctob/add-set lib' (ctob/make-token-set token-set))
:else :else

View File

@@ -885,7 +885,7 @@
(assert-library! changes) (assert-library! changes)
(let [library-data (::library-data (meta changes)) (let [library-data (::library-data (meta changes))
prev-token (some-> (get library-data :tokens-lib) prev-token (some-> (get library-data :tokens-lib)
(ctob/set-by-name set-name) (ctob/get-set-by-name set-name)
(ctob/get-token token-id))] (ctob/get-token token-id))]
(-> changes (-> changes
(update :redo-changes conj {:type :set-token (update :redo-changes conj {:type :set-token

View File

@@ -213,12 +213,11 @@
;; === Token Set ;; === Token Set
(defprotocol ITokenSet (defprotocol ITokenSet
(token-by-id [_ id] "get a token by its id")
(token-by-name [_ id] "get a token by its name")
(add-token [_ token] "add a token at the end of the list") (add-token [_ token] "add a token at the end of the list")
(update-token [_ id f] "update a token in the list") (update-token [_ id f] "update a token in the list")
(delete-token [_ id] "delete a token from the list") (delete-token [_ id] "delete a token from the list")
(get-token [_ id] "return token by id") (get-token [_ id] "get a token by its id")
(get-token-by-name [_ id] "get a token by its name")
(get-tokens [_] "return an ordered sequence of all tokens in the set") (get-tokens [_] "return an ordered sequence of all tokens in the set")
(get-tokens-map [_] "return a map of tokens in the set, indexed by token-name")) (get-tokens-map [_] "return a map of tokens in the set, indexed by token-name"))
@@ -287,13 +286,6 @@
tokens)) tokens))
ITokenSet ITokenSet
(token-by-id [_ id]
(some #(when (= (:id %) id) %) ;; TODO: this will be made in an efficient way when
(vals tokens))) ;; we refactor the tokens lib internal structure
(token-by-name [_ name]
(get tokens name))
(add-token [_ token] (add-token [_ token]
(let [token (check-token token)] (let [token (check-token token)]
(TokenSet. id (TokenSet. id
@@ -303,7 +295,7 @@
(assoc tokens (:name token) token)))) (assoc tokens (:name token) token))))
(update-token [this token-id f] (update-token [this token-id f]
(if-let [token (token-by-id this token-id)] (if-let [token (get-token this token-id)]
(let [token' (-> (make-token (f token)) (let [token' (-> (make-token (f token))
(assoc :modified-at (ct/now)))] (assoc :modified-at (ct/now)))]
(TokenSet. id (TokenSet. id
@@ -318,15 +310,19 @@
this)) this))
(delete-token [this token-id] (delete-token [this token-id]
(let [token (token-by-id this token-id)] (let [token (get-token this token-id)]
(TokenSet. id (TokenSet. id
name name
description description
(ct/now) (ct/now)
(dissoc tokens (:name token))))) (dissoc tokens (:name token)))))
(get-token [this id] ;; TODO: this is redundant, may be removed (get-token [_ id]
(token-by-id this id)) (some #(when (= (:id %) id) %) ;; TODO: this will be made in an efficient way when
(vals tokens))) ;; we refactor the tokens lib internal structure
(get-token-by-name [_ name]
(get tokens name))
(get-tokens [_] (get-tokens [_]
(vals tokens)) (vals tokens))
@@ -557,8 +553,6 @@
Prefixed set path or ppath: a path wit added prefixes [\"G-some-group\", \"G-some-subgroup\"]. Prefixed set path or ppath: a path wit added prefixes [\"G-some-group\", \"G-some-subgroup\"].
Prefixed set full path or pfpath: a full path wit prefixes [\"G-some-group\", \"G-some-subgroup\", \"S-some-set\"]. Prefixed set full path or pfpath: a full path wit prefixes [\"G-some-group\", \"G-some-subgroup\", \"S-some-set\"].
Prefixed set final name or pfname: a final name with prefix \"S-some-set\"." Prefixed set final name or pfname: a final name with prefix \"S-some-set\"."
(set-by-id [_ id] "get a set by its id")
(set-by-name [_ name] "get a set by its name")
(add-set [_ token-set] "add a set to the library, at the end") (add-set [_ token-set] "add a set to the library, at the end")
(update-set [_ set-name f] "modify a set in the library") (update-set [_ set-name f] "modify a set in the library")
(delete-set-path [_ set-path] "delete a set in the library") (delete-set-path [_ set-path] "delete a set in the library")
@@ -573,7 +567,8 @@
(get-sets-at-path [_ path-str] "get an ordered sequence of sets at `path` in the library") (get-sets-at-path [_ path-str] "get an ordered sequence of sets at `path` in the library")
(rename-set-group [_ from-path-str to-path-str] "renames set groups and all child set names from `from-path-str` to `to-path-str`") (rename-set-group [_ from-path-str to-path-str] "renames set groups and all child set names from `from-path-str` to `to-path-str`")
(get-ordered-set-names [_] "get an ordered sequence of all sets names in the library") (get-ordered-set-names [_] "get an ordered sequence of all sets names in the library")
(get-set [_ set-name] "get one set looking for name")) (get-set [_ id] "get a set looking by id")
(get-set-by-name [_ name] "get a set looking by name"))
(def ^:private schema:token-set-node (def ^:private schema:token-set-node
[:schema {:registry {::node [:schema {:registry {::node
@@ -950,7 +945,7 @@
(set-group-path-exists? [_ path] "if a set group at `path` exists") (set-group-path-exists? [_ path] "if a set group at `path` exists")
(add-token-in-set [_ set-id token] "add token to a set") (add-token-in-set [_ set-id token] "add token to a set")
(get-token-in-set [_ set-id token-id] "get token in a set") (get-token-in-set [_ set-id token-id] "get token in a set")
(get-token-by-name [_ set-id token-name] "get token in a set searching by token name") (get-token-in-set-by-name [_ set-id token-name] "get token in a set searching by token name")
(update-token-in-set [_ set-id token-id f] "update a token in a set") (update-token-in-set [_ set-id token-id f] "update a token in a set")
(delete-token-from-set [_ set-id token-id] "delete a token from a set") (delete-token-from-set [_ set-id token-id] "delete a token from a set")
(toggle-set-in-theme [_ group-name theme-name set-name] "toggle a set used / not used in a theme") (toggle-set-in-theme [_ group-name theme-name set-name] "toggle a set used / not used in a theme")
@@ -980,14 +975,6 @@ Will return a value that matches this schema:
(-write [this writter options] (json/-write (export-dtcg-json this) writter options))]) (-write [this writter options] (json/-write (export-dtcg-json this) writter options))])
ITokenSets ITokenSets
(set-by-id [this id]
(some #(when (= (get-id %) id) %) ;; TODO: this will be made in an efficient way when
(get-sets this))) ;; we refactor the tokens lib internal structure
(set-by-name [_ name]
(let [path (set-name->prefixed-full-path name)]
(get-in sets path)))
(add-set [_ token-set] (add-set [_ token-set]
(assert (token-set? token-set) "expected valid token-set") (assert (token-set? token-set) "expected valid token-set")
(let [path (get-set-prefixed-path token-set)] (let [path (get-set-prefixed-path token-set)]
@@ -1186,8 +1173,13 @@ Will return a value that matches this schema:
(set-count [this] (set-count [this]
(count (get-sets this))) (count (get-sets this)))
(get-set [this set-id] ;; TODO: this is redundant and should be removed (get-set [this id]
(set-by-id this set-id)) (some #(when (= (get-id %) id) %) ;; TODO: this will be made in an efficient way when
(get-sets this))) ;; we refactor the tokens lib internal structure
(get-set-by-name [_ name]
(let [path (set-name->prefixed-full-path name)]
(get-in sets path)))
ITokenThemes ITokenThemes
(add-theme [_ token-theme] (add-theme [_ token-theme]
@@ -1306,10 +1298,10 @@ Will return a value that matches this schema:
(get-set set-id) (get-set set-id)
(get-token token-id))) (get-token token-id)))
(get-token-by-name [this set-id token-name] (get-token-in-set-by-name [this set-id token-name]
(some-> this (some-> this
(get-set set-id) (get-set set-id)
(token-by-name token-name))) (get-token-by-name token-name)))
(update-token-in-set [this set-name token-id f] (update-token-in-set [this set-name token-id f]
(update-set this set-name #(update-token % token-id f))) (update-set this set-name #(update-token % token-id f)))
@@ -1349,7 +1341,7 @@ Will return a value that matches this schema:
all-set-names (get-ordered-set-names this) all-set-names (get-ordered-set-names this)
active-set-names (filter theme-set-names all-set-names) active-set-names (filter theme-set-names all-set-names)
tokens (reduce (fn [tokens set-name] tokens (reduce (fn [tokens set-name]
(let [set (set-by-name this set-name)] (let [set (get-set-by-name this set-name)]
(merge tokens (get-tokens-map set)))) (merge tokens (get-tokens-map set))))
(d/ordered-map) (d/ordered-map)
active-set-names)] active-set-names)]

View File

@@ -406,7 +406,6 @@
(ctob/add-token-in-set "test-token-set" token) (ctob/add-token-in-set "test-token-set" token)
(ctob/add-token-in-set "not-existing-set" token)) (ctob/add-token-in-set "not-existing-set" token))
_ (prn "tokens-lib'" (datafy tokens-lib'))
token-set (ctob/get-set tokens-lib (thi/id :test-token-set)) token-set (ctob/get-set tokens-lib (thi/id :test-token-set))
token-set' (ctob/get-set tokens-lib' (thi/id :test-token-set)) token-set' (ctob/get-set tokens-lib' (thi/id :test-token-set))
token' (ctob/get-token token-set' (thi/id :token))] token' (ctob/get-token token-set' (thi/id :token))]
@@ -1282,20 +1281,20 @@
(let [json (-> (slurp "test/common_tests/types/data/tokens-single-set-legacy-example.json") (let [json (-> (slurp "test/common_tests/types/data/tokens-single-set-legacy-example.json")
(json/decode {:key-fn identity})) (json/decode {:key-fn identity}))
lib (ctob/parse-decoded-json json "single_set") lib (ctob/parse-decoded-json json "single_set")
token-set (ctob/set-by-name lib "single_set")] token-set (ctob/get-set-by-name lib "single_set")]
(t/is (= '("single_set") (ctob/get-ordered-set-names lib))) (t/is (= '("single_set") (ctob/get-ordered-set-names lib)))
(t/testing "token added" (t/testing "token added"
(t/is (some? (ctob/get-token-by-name lib (ctob/get-id token-set) "color.red.100"))))))) (t/is (some? (ctob/get-token-in-set-by-name lib (ctob/get-id token-set) "color.red.100")))))))
#?(:clj #?(:clj
(t/deftest parse-single-set-dtcg-json (t/deftest parse-single-set-dtcg-json
(let [json (-> (slurp "test/common_tests/types/data/tokens-single-set-dtcg-example.json") (let [json (-> (slurp "test/common_tests/types/data/tokens-single-set-dtcg-example.json")
(json/decode {:key-fn identity})) (json/decode {:key-fn identity}))
lib (ctob/parse-decoded-json json "single_set") lib (ctob/parse-decoded-json json "single_set")
token-set (ctob/set-by-name lib "single_set")] token-set (ctob/get-set-by-name lib "single_set")]
(t/is (= '("single_set") (ctob/get-ordered-set-names lib))) (t/is (= '("single_set") (ctob/get-ordered-set-names lib)))
(t/testing "token added" (t/testing "token added"
(t/is (some? (ctob/get-token-by-name lib (ctob/get-id token-set) "color.red.100"))))))) (t/is (some? (ctob/get-token-in-set-by-name lib (ctob/get-id token-set) "color.red.100")))))))
#?(:clj #?(:clj
(t/deftest parse-multi-set-legacy-json (t/deftest parse-multi-set-legacy-json
@@ -1303,31 +1302,31 @@
(json/decode {:key-fn identity})) (json/decode {:key-fn identity}))
lib (ctob/parse-decoded-json json "") lib (ctob/parse-decoded-json json "")
token-theme (ctob/get-theme lib "group-1" "theme-1") token-theme (ctob/get-theme lib "group-1" "theme-1")
core-set (ctob/set-by-name lib "core") core-set (ctob/get-set-by-name lib "core")
theme-set (ctob/set-by-name lib "theme")] theme-set (ctob/get-set-by-name lib "theme")]
(t/is (= '("core" "light" "dark" "theme") (ctob/get-ordered-set-names lib))) (t/is (= '("core" "light" "dark" "theme") (ctob/get-ordered-set-names lib)))
(t/testing "set exists in theme" (t/testing "set exists in theme"
(t/is (= (:group token-theme) "group-1")) (t/is (= (:group token-theme) "group-1"))
(t/is (= (:name token-theme) "theme-1")) (t/is (= (:name token-theme) "theme-1"))
(t/is (= (:sets token-theme) #{"light"}))) (t/is (= (:sets token-theme) #{"light"})))
(t/testing "tokens exist in core set" (t/testing "tokens exist in core set"
(t/is (tht/token-data-eq? (ctob/get-token-by-name lib (ctob/get-id core-set) "colors.red.600") (t/is (tht/token-data-eq? (ctob/get-token-in-set-by-name lib (ctob/get-id core-set) "colors.red.600")
{:name "colors.red.600" {:name "colors.red.600"
:type :color :type :color
:value "#e53e3e" :value "#e53e3e"
:description ""})) :description ""}))
(t/is (tht/token-data-eq? (ctob/get-token-by-name lib (ctob/get-id core-set) "spacing.multi-value") (t/is (tht/token-data-eq? (ctob/get-token-in-set-by-name lib (ctob/get-id core-set) "spacing.multi-value")
{:name "spacing.multi-value" {:name "spacing.multi-value"
:type :spacing :type :spacing
:value "{dimension.sm} {dimension.xl}" :value "{dimension.sm} {dimension.xl}"
:description "You can have multiple values in a single spacing token"})) :description "You can have multiple values in a single spacing token"}))
(t/is (tht/token-data-eq? (ctob/get-token-by-name lib (ctob/get-id theme-set) "button.primary.background") (t/is (tht/token-data-eq? (ctob/get-token-in-set-by-name lib (ctob/get-id theme-set) "button.primary.background")
{:name "button.primary.background" {:name "button.primary.background"
:type :color :type :color
:value "{accent.default}" :value "{accent.default}"
:description ""}))) :description ""})))
(t/testing "invalid tokens got discarded" (t/testing "invalid tokens got discarded"
(t/is (nil? (ctob/get-token-by-name lib (ctob/get-id theme-set) "boxShadow.default"))))))) (t/is (nil? (ctob/get-token-in-set-by-name lib (ctob/get-id theme-set) "boxShadow.default")))))))
#?(:clj #?(:clj
(t/deftest parse-multi-set-dtcg-json (t/deftest parse-multi-set-dtcg-json
@@ -1335,31 +1334,31 @@
(json/decode {:key-fn identity})) (json/decode {:key-fn identity}))
lib (ctob/parse-decoded-json json "") lib (ctob/parse-decoded-json json "")
token-theme (ctob/get-theme lib "group-1" "theme-1") token-theme (ctob/get-theme lib "group-1" "theme-1")
core-set (ctob/set-by-name lib "core") core-set (ctob/get-set-by-name lib "core")
theme-set (ctob/set-by-name lib "theme")] theme-set (ctob/get-set-by-name lib "theme")]
(t/is (= '("core" "light" "dark" "theme") (ctob/get-ordered-set-names lib))) (t/is (= '("core" "light" "dark" "theme") (ctob/get-ordered-set-names lib)))
(t/testing "set exists in theme" (t/testing "set exists in theme"
(t/is (= (:group token-theme) "group-1")) (t/is (= (:group token-theme) "group-1"))
(t/is (= (:name token-theme) "theme-1")) (t/is (= (:name token-theme) "theme-1"))
(t/is (= (:sets token-theme) #{"light"}))) (t/is (= (:sets token-theme) #{"light"})))
(t/testing "tokens exist in core set" (t/testing "tokens exist in core set"
(t/is (tht/token-data-eq? (ctob/get-token-by-name lib (ctob/get-id core-set) "colors.red.600") (t/is (tht/token-data-eq? (ctob/get-token-in-set-by-name lib (ctob/get-id core-set) "colors.red.600")
{:name "colors.red.600" {:name "colors.red.600"
:type :color :type :color
:value "#e53e3e" :value "#e53e3e"
:description ""})) :description ""}))
(t/is (tht/token-data-eq? (ctob/get-token-by-name lib (ctob/get-id core-set) "spacing.multi-value") (t/is (tht/token-data-eq? (ctob/get-token-in-set-by-name lib (ctob/get-id core-set) "spacing.multi-value")
{:name "spacing.multi-value" {:name "spacing.multi-value"
:type :spacing :type :spacing
:value "{dimension.sm} {dimension.xl}" :value "{dimension.sm} {dimension.xl}"
:description "You can have multiple values in a single spacing token"})) :description "You can have multiple values in a single spacing token"}))
(t/is (tht/token-data-eq? (ctob/get-token-by-name lib (ctob/get-id theme-set) "button.primary.background") (t/is (tht/token-data-eq? (ctob/get-token-in-set-by-name lib (ctob/get-id theme-set) "button.primary.background")
{:name "button.primary.background" {:name "button.primary.background"
:type :color :type :color
:value "{accent.default}" :value "{accent.default}"
:description ""}))) :description ""})))
(t/testing "invalid tokens got discarded" (t/testing "invalid tokens got discarded"
(t/is (nil? (ctob/get-token-by-name lib (ctob/get-id theme-set) "boxShadow.default"))))))) (t/is (nil? (ctob/get-token-in-set-by-name lib (ctob/get-id theme-set) "boxShadow.default")))))))
#?(:clj #?(:clj
(t/deftest parse-multi-set-dtcg-json-default-team (t/deftest parse-multi-set-dtcg-json-default-team
@@ -1368,14 +1367,14 @@
lib (ctob/parse-decoded-json json "") lib (ctob/parse-decoded-json json "")
themes (ctob/get-themes lib) themes (ctob/get-themes lib)
first-theme (first themes) first-theme (first themes)
dark-set (ctob/set-by-name lib "dark")] dark-set (ctob/get-set-by-name lib "dark")]
(t/is (= '("dark") (ctob/get-ordered-set-names lib))) (t/is (= '("dark") (ctob/get-ordered-set-names lib)))
(t/is (= 1 (count themes))) (t/is (= 1 (count themes)))
(t/testing "existing theme is default theme" (t/testing "existing theme is default theme"
(t/is (= (:group first-theme) "")) (t/is (= (:group first-theme) ""))
(t/is (= (:name first-theme) ctob/hidden-theme-name))) (t/is (= (:name first-theme) ctob/hidden-theme-name)))
(t/testing "token exist in dark set" (t/testing "token exist in dark set"
(t/is (tht/token-data-eq? (ctob/get-token-by-name lib (ctob/get-id dark-set) "small") (t/is (tht/token-data-eq? (ctob/get-token-in-set-by-name lib (ctob/get-id dark-set) "small")
{:name "small" {:name "small"
:value "8" :value "8"
:type :border-radius :type :border-radius

View File

@@ -6,7 +6,6 @@
(ns app.main.data.workspace.tokens.library-edit (ns app.main.data.workspace.tokens.library-edit
(:require (:require
[app.common.data :as d]
[app.common.data.macros :as dm] [app.common.data.macros :as dm]
[app.common.files.changes-builder :as pcb] [app.common.files.changes-builder :as pcb]
[app.common.files.helpers :as cfh] [app.common.files.helpers :as cfh]
@@ -23,8 +22,6 @@
[app.main.data.workspace.tokens.propagation :as dwtp] [app.main.data.workspace.tokens.propagation :as dwtp]
[app.util.i18n :refer [tr]] [app.util.i18n :refer [tr]]
[beicon.v2.core :as rx] [beicon.v2.core :as rx]
[clojure.datafy :refer [datafy]]
[clojure.test :as ct]
[potok.v2.core :as ptk])) [potok.v2.core :as ptk]))
(declare set-selected-token-set-name) (declare set-selected-token-set-name)
@@ -153,7 +150,7 @@
(let [data (dsh/lookup-file-data state) (let [data (dsh/lookup-file-data state)
tokens-lib (get data :tokens-lib) tokens-lib (get data :tokens-lib)
set-name (ctob/normalize-set-name set-name)] set-name (ctob/normalize-set-name set-name)]
(if (and tokens-lib (ctob/set-by-name tokens-lib set-name)) (if (and tokens-lib (ctob/get-set-by-name tokens-lib set-name))
(rx/of (ntf/show {:content (tr "errors.token-set-already-exists") (rx/of (ntf/show {:content (tr "errors.token-set-already-exists")
:type :toast :type :toast
:level :error :level :error
@@ -184,7 +181,7 @@
name (ctob/normalize-set-name name (ctob/get-name token-set)) name (ctob/normalize-set-name name (ctob/get-name token-set))
tokens-lib (get data :tokens-lib)] tokens-lib (get data :tokens-lib)]
(if (ctob/set-by-name tokens-lib name) (if (ctob/get-set-by-name tokens-lib name)
(rx/of (ntf/show {:content (tr "errors.token-set-already-exists") (rx/of (ntf/show {:content (tr "errors.token-set-already-exists")
:type :toast :type :toast
:level :error :level :error

View File

@@ -24,8 +24,8 @@
(dwti/import-file-stream "core") (dwti/import-file-stream "core")
(rx/subs! (fn [tokens-lib] (rx/subs! (fn [tokens-lib]
(t/is (instance? ctob/TokensLib tokens-lib)) (t/is (instance? ctob/TokensLib tokens-lib))
(t/is (= "red" (-> (ctob/set-by-name tokens-lib "core") (t/is (= "red" (-> (ctob/get-set-by-name tokens-lib "core")
(ctob/token-by-name "color") (ctob/get-token-by-name "color")
(:value)))) (:value))))
(done)))))))) (done))))))))
@@ -96,7 +96,7 @@ color.value tries to reference missing, which is not defined.")))
(->> (rx/of json) (->> (rx/of json)
(dwti/import-file-stream "") (dwti/import-file-stream "")
(rx/subs! (fn [tokens-lib] (rx/subs! (fn [tokens-lib]
(let [token-set (ctob/set-by-name tokens-lib "core")] (let [token-set (ctob/get-set-by-name tokens-lib "core")]
(t/is (instance? ctob/TokensLib tokens-lib)) (t/is (instance? ctob/TokensLib tokens-lib))
(t/is (= "{missing}" (:value (ctob/get-token-by-name tokens-lib (ctob/get-id token-set) "color")))) (t/is (= "{missing}" (:value (ctob/get-token-in-set-by-name tokens-lib (ctob/get-id token-set) "color"))))
(done))))))))) (done)))))))))

View File

@@ -43,7 +43,7 @@
(let [file' (ths/get-file-from-state new-state) (let [file' (ths/get-file-from-state new-state)
tokens-lib' (toht/get-tokens-lib file') tokens-lib' (toht/get-tokens-lib file')
sets' (ctob/get-sets tokens-lib') sets' (ctob/get-sets tokens-lib')
set-b' (ctob/set-by-name tokens-lib' "Set B")] set-b' (ctob/get-set-by-name tokens-lib' "Set B")]
(t/testing "Token lib contains two sets" (t/testing "Token lib contains two sets"
(t/is (= (count sets') 2)) (t/is (= (count sets') 2))
@@ -55,7 +55,7 @@
(let [file (setup-file-with-token-lib) (let [file (setup-file-with-token-lib)
store (ths/setup-store file) store (ths/setup-store file)
tokens-lib (toht/get-tokens-lib file) tokens-lib (toht/get-tokens-lib file)
set-a (ctob/set-by-name tokens-lib "Set A") set-a (ctob/get-set-by-name tokens-lib "Set A")
events [(dwtl/update-token-set (ctob/rename set-a "Set A updated") events [(dwtl/update-token-set (ctob/rename set-a "Set A updated")
"Set A updated")]] "Set A updated")]]
@@ -65,7 +65,7 @@
(let [file' (ths/get-file-from-state new-state) (let [file' (ths/get-file-from-state new-state)
tokens-lib' (toht/get-tokens-lib file') tokens-lib' (toht/get-tokens-lib file')
sets' (ctob/get-sets tokens-lib') sets' (ctob/get-sets tokens-lib')
set-a' (ctob/set-by-name tokens-lib' "Set A updated")] set-a' (ctob/get-set-by-name tokens-lib' "Set A updated")]
(t/testing "Set has been renamed" (t/testing "Set has been renamed"
(t/is (= (count sets') 1)) (t/is (= (count sets') 1))