@adobe/spectrum-tokens 14.2.1 → 14.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +10 -0
- package/moon.yml +47 -1
- package/naming-exceptions.json +1170 -0
- package/package.json +5 -1
- package/schemas/token-file.json +33 -0
- package/schemas/token-types/multiplier.json +1 -2
- package/snapshots/validation-snapshot.json +1363 -0
- package/test/tokenSchemaValidator.test.js +22 -16
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright
|
|
2
|
+
Copyright 2026 Adobe. All rights reserved.
|
|
3
3
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
5
|
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -38,6 +38,10 @@ test.before(async (t) => {
|
|
|
38
38
|
);
|
|
39
39
|
t.context.schemaIds = schemaIds;
|
|
40
40
|
|
|
41
|
+
const tokenFileSchema = await readJSON("schemas/token-file.json");
|
|
42
|
+
ajv.addSchema(tokenFileSchema, tokenFileSchema["$id"]);
|
|
43
|
+
t.context.tokenFileSchemaId = tokenFileSchema["$id"];
|
|
44
|
+
|
|
41
45
|
const tokenFilesNames = await glob("src/*.json");
|
|
42
46
|
t.context.tokenFiles = await Promise.all(
|
|
43
47
|
tokenFilesNames.map(async (tokenFile) => {
|
|
@@ -46,21 +50,9 @@ test.before(async (t) => {
|
|
|
46
50
|
);
|
|
47
51
|
});
|
|
48
52
|
|
|
49
|
-
test("
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
53
|
-
type: "object",
|
|
54
|
-
patternProperties: {
|
|
55
|
-
"^(?:(?:[a-z]|\\d)+-?)*(?:[a-z]|\\d)+$": {
|
|
56
|
-
anyOf: t.context.schemaIds.map((schemaId) => ({ $ref: schemaId })),
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
} catch (error) {
|
|
61
|
-
console.log(error);
|
|
62
|
-
}
|
|
63
|
-
t.pass();
|
|
53
|
+
test("token-file schema compiles", (t) => {
|
|
54
|
+
const validate = ajv.getSchema(t.context.tokenFileSchemaId);
|
|
55
|
+
t.truthy(validate, "token-file schema should be registered");
|
|
64
56
|
});
|
|
65
57
|
|
|
66
58
|
test("Every token should have a $schema property", (t) => {
|
|
@@ -95,3 +87,17 @@ test("Every token schema should validate against the definition", (t) => {
|
|
|
95
87
|
});
|
|
96
88
|
t.deepEqual(errors, []);
|
|
97
89
|
});
|
|
90
|
+
|
|
91
|
+
test("Every token file validates against token-file.json", (t) => {
|
|
92
|
+
const errors = [];
|
|
93
|
+
t.context.tokenFiles.forEach((tokenFileObj) => {
|
|
94
|
+
if (!ajv.validate(t.context.tokenFileSchemaId, tokenFileObj.data)) {
|
|
95
|
+
t.log(`${tokenFileObj.fileName} failed token-file validation.`);
|
|
96
|
+
errors.push({
|
|
97
|
+
fileName: tokenFileObj.fileName,
|
|
98
|
+
errors: ajv.errors,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
t.deepEqual(errors, []);
|
|
103
|
+
});
|