mirror of
https://github.com/penpot/penpot.git
synced 2025-12-12 06:24:17 +01:00
🐛 Fix validation issues with dtcg-node schema
This commit is contained in:
@@ -1460,16 +1460,19 @@ Will return a value that matches this schema:
|
||||
["type" :string]]]))
|
||||
|
||||
(def ^:private schema:dtcg-node
|
||||
[:schema {:registry
|
||||
{::simple-value
|
||||
[:or :string :int :double]
|
||||
::value
|
||||
[:or
|
||||
[:ref ::simple-value]
|
||||
[:vector ::simple-value]
|
||||
[:map-of :string [:or
|
||||
[:ref ::simple-value]
|
||||
[:vector ::simple-value]]]]}}
|
||||
[:map
|
||||
["$value" :string]
|
||||
["$type" :string]]
|
||||
[:map
|
||||
["$value" [:sequential [:map ["$type" :string]]]]
|
||||
["$type" :string]]
|
||||
[:map
|
||||
["$value" :map]
|
||||
["$type" :string]]])
|
||||
["$type" :string]
|
||||
["$value" [:ref ::value]]]])
|
||||
|
||||
(def ^:private dtcg-node?
|
||||
(sm/validator schema:dtcg-node))
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 1.1.0-RC1
|
||||
## 1.1.0-RC2
|
||||
|
||||
- Fix validation issue with several token nodes
|
||||
|
||||
|
||||
## 1.1.0-RC2
|
||||
|
||||
- Add experimental addTokensLib method
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@penpot/library",
|
||||
"version": "1.1.0-RC1",
|
||||
"version": "1.1.0-RC2",
|
||||
"license": "MPL-2.0",
|
||||
"author": "Kaleidos INC",
|
||||
"packageManager": "yarn@4.10.3+sha512.c38cafb5c7bb273f3926d04e55e1d8c9dfa7d9c3ea1f36a4868fa028b9e5f72298f0b7f401ad5eb921749eb012eb1c3bb74bf7503df3ee43fd600d14a018266f",
|
||||
|
||||
21
library/test/_tokens-2.json
Normal file
21
library/test/_tokens-2.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"Global": {
|
||||
"font-1": {
|
||||
"$value": [
|
||||
"Abel"
|
||||
],
|
||||
"$type": "fontFamilies",
|
||||
"$description": ""
|
||||
}
|
||||
},
|
||||
"$themes": [],
|
||||
"$metadata": {
|
||||
"tokenSetOrder": [
|
||||
"Global"
|
||||
],
|
||||
"activeThemes": [],
|
||||
"activeSets": [
|
||||
"Global"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -149,6 +149,27 @@ test("create context with tokens lib as json", () => {
|
||||
assert.ok(file.data.tokensLib)
|
||||
});
|
||||
|
||||
test("create context with tokens lib as json 2", () => {
|
||||
const context = penpot.createBuildContext();
|
||||
|
||||
const fileId = context.addFile({name: "file 1"});
|
||||
const pageId = context.addPage({name: "page 1"});
|
||||
|
||||
|
||||
const tokensFilePath = path.join(__dirname, "_tokens-2.json");
|
||||
const tokens = fs.readFileSync(tokensFilePath, "utf8");
|
||||
|
||||
context.addTokensLib(tokens);
|
||||
|
||||
const internalState = context.getInternalState();
|
||||
const file = internalState.files[fileId];
|
||||
|
||||
assert.ok(file, "file should exist");
|
||||
|
||||
assert.ok(file.data);
|
||||
assert.ok(file.data.tokensLib)
|
||||
});
|
||||
|
||||
test("create context with tokens lib as obj", () => {
|
||||
const context = penpot.createBuildContext();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user