@primer/primitives 7.17.0-rc.61b28bca → 7.17.0-rc.9ef8a8c3
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/dist/css/functional/themes/dark-colorblind.css +14 -14
- package/dist/css/functional/themes/dark-tritanopia.css +14 -14
- package/dist/css/functional/themes/dark.css +14 -14
- package/dist/docs/functional/themes/dark-colorblind.json +7 -7
- package/dist/docs/functional/themes/dark-tritanopia.json +7 -7
- package/dist/docs/functional/themes/dark.json +7 -7
- package/dist/figma/scales/dark.json +5 -5
- package/dist/figma/themes/dark-colorblind.json +20 -20
- package/dist/figma/themes/dark-tritanopia.json +20 -20
- package/dist/figma/themes/dark.json +20 -20
- package/dist/internalCss/dark-colorblind.css +18 -18
- package/dist/internalCss/dark-tritanopia.css +18 -18
- package/dist/internalCss/dark.css +18 -18
- package/dist/styleLint/functional/themes/dark-colorblind.json +7 -7
- package/dist/styleLint/functional/themes/dark-tritanopia.json +7 -7
- package/dist/styleLint/functional/themes/dark.json +7 -7
- package/package.json +1 -1
- package/src/formats/jsonFigma.ts +2 -0
- package/src/platforms/figma.ts +1 -1
- package/src/schemas/collections.ts +2 -0
- package/src/schemas/dimensionToken.ts +1 -1
- package/src/schemas/fontFamilyToken.ts +10 -0
- package/src/schemas/fontWeightToken.ts +10 -0
- package/src/tokens/base/color/dark/dark.json5 +2 -2
- package/tokens-v2-private/css/tokens/base/size/size.css +1 -1
- package/tokens-v2-private/css/tokens/base/typography/typography.css +1 -1
- package/tokens-v2-private/css/tokens/functional/size/border.css +1 -1
- package/tokens-v2-private/css/tokens/functional/size/breakpoints.css +1 -1
- package/tokens-v2-private/css/tokens/functional/size/size-coarse.css +1 -1
- package/tokens-v2-private/css/tokens/functional/size/size-fine.css +1 -1
- package/tokens-v2-private/css/tokens/functional/size/size.css +1 -1
- package/tokens-v2-private/css/tokens/functional/typography/typography.css +1 -1
- package/tokens-v2-private/js/module/tokens/base/size/size.js +1 -1
- package/tokens-v2-private/js/module/tokens/base/typography/typography.js +1 -1
- package/tokens-v2-private/js/module/tokens/functional/size/border.js +1 -1
- package/tokens-v2-private/js/module/tokens/functional/size/breakpoints.js +1 -1
- package/tokens-v2-private/js/module/tokens/functional/size/size-coarse.js +1 -1
- package/tokens-v2-private/js/module/tokens/functional/size/size-fine.js +1 -1
- package/tokens-v2-private/js/module/tokens/functional/size/size.js +1 -1
- package/tokens-v2-private/js/module/tokens/functional/size/viewport.js +1 -1
- package/tokens-v2-private/js/module/tokens/functional/typography/typography.js +1 -1
- package/tokens-v2-private/js/tokens/base/size/size.js +1 -1
- package/tokens-v2-private/js/tokens/base/typography/typography.js +1 -1
- package/tokens-v2-private/js/tokens/functional/size/border.js +1 -1
- package/tokens-v2-private/js/tokens/functional/size/breakpoints.js +1 -1
- package/tokens-v2-private/js/tokens/functional/size/size-coarse.js +1 -1
- package/tokens-v2-private/js/tokens/functional/size/size-fine.js +1 -1
- package/tokens-v2-private/js/tokens/functional/size/size.js +1 -1
- package/tokens-v2-private/js/tokens/functional/size/viewport.js +1 -1
- package/tokens-v2-private/js/tokens/functional/typography/typography.js +1 -1
- package/tokens-v2-private/scss/tokens/base/size/size.scss +1 -1
- package/tokens-v2-private/scss/tokens/base/typography/typography.scss +1 -1
- package/tokens-v2-private/scss/tokens/functional/size/border.scss +1 -1
- package/tokens-v2-private/scss/tokens/functional/size/breakpoints.scss +1 -1
- package/tokens-v2-private/scss/tokens/functional/size/size-coarse.scss +1 -1
- package/tokens-v2-private/scss/tokens/functional/size/size-fine.scss +1 -1
- package/tokens-v2-private/scss/tokens/functional/size/size.scss +1 -1
- package/tokens-v2-private/scss/tokens/functional/size/viewport.scss +1 -1
- package/tokens-v2-private/scss/tokens/functional/typography/typography.scss +1 -1
- package/tokens-v2-private/ts/tokens/base/size/size.d.ts +1 -1
- package/tokens-v2-private/ts/tokens/base/size/size.js +1 -1
- package/tokens-v2-private/ts/tokens/base/typography/typography.d.ts +1 -1
- package/tokens-v2-private/ts/tokens/base/typography/typography.js +1 -1
- package/tokens-v2-private/ts/tokens/functional/size/border.d.ts +1 -1
- package/tokens-v2-private/ts/tokens/functional/size/border.js +1 -1
- package/tokens-v2-private/ts/tokens/functional/size/breakpoints.d.ts +1 -1
- package/tokens-v2-private/ts/tokens/functional/size/breakpoints.js +1 -1
- package/tokens-v2-private/ts/tokens/functional/size/size-coarse.d.ts +1 -1
- package/tokens-v2-private/ts/tokens/functional/size/size-coarse.js +1 -1
- package/tokens-v2-private/ts/tokens/functional/size/size-fine.d.ts +1 -1
- package/tokens-v2-private/ts/tokens/functional/size/size-fine.js +1 -1
- package/tokens-v2-private/ts/tokens/functional/size/size.d.ts +1 -1
- package/tokens-v2-private/ts/tokens/functional/size/size.js +1 -1
- package/tokens-v2-private/ts/tokens/functional/size/viewport.d.ts +1 -1
- package/tokens-v2-private/ts/tokens/functional/size/viewport.js +1 -1
- package/tokens-v2-private/ts/tokens/functional/typography/typography.d.ts +1 -1
- package/tokens-v2-private/ts/tokens/functional/typography/typography.js +1 -1
- package/src/filters/isBorder.test.ts +0 -18
- package/src/filters/isColor.test.ts +0 -22
- package/src/filters/isColorWithAlpha.test.ts +0 -34
- package/src/filters/isColorWithMix.test.ts +0 -108
- package/src/filters/isDeprecated.test.ts +0 -56
- package/src/filters/isDimension.test.ts +0 -22
- package/src/filters/isDuration.test.ts +0 -22
- package/src/filters/isFontFamily.test.ts +0 -22
- package/src/filters/isFontWeight.test.ts +0 -22
- package/src/filters/isFromFile.test.ts +0 -34
- package/src/filters/isShadow.test.ts +0 -18
- package/src/filters/isSource.test.ts +0 -44
- package/src/filters/isTypography.test.ts +0 -18
- package/src/formats/cssCustomMedia.test.ts +0 -11
- package/src/formats/cssThemed.test.ts +0 -87
- package/src/formats/cssWrapMediaQuery.test.ts +0 -170
- package/src/formats/javascriptCommonJs.test.ts +0 -43
- package/src/formats/javascriptEsm.test.ts +0 -41
- package/src/formats/jsonNestedPrefixed.test.ts +0 -73
- package/src/formats/jsonOneDimensional.test.ts +0 -56
- package/src/formats/typescriptExportDefinition.test.ts +0 -178
- package/src/formats/utilities/jsonToFlat.test.ts +0 -47
- package/src/formats/utilities/jsonToNestedValue.test.ts +0 -39
- package/src/formats/utilities/prefixTokens.test.ts +0 -38
- package/src/parsers/w3cJsonParser.test.ts +0 -35
- package/src/schemas/alphaValueSchema.test.ts +0 -24
- package/src/schemas/baseTokenSchema.test.ts +0 -17
- package/src/schemas/borderTokenSchema.test.ts +0 -53
- package/src/schemas/collectionSchema.test.ts +0 -58
- package/src/schemas/colorHexValueSchema.test.ts +0 -26
- package/src/schemas/colorTokenSchema.test.ts +0 -27
- package/src/schemas/dimensionTokenSchema.test.ts +0 -28
- package/src/schemas/dimensionValueSchema.test.ts +0 -21
- package/src/schemas/durationTokenSchema.test.ts +0 -58
- package/src/schemas/durationValueSchema.test.ts +0 -25
- package/src/schemas/fontFamilyTokenSchema.test.ts +0 -82
- package/src/schemas/fontWeightTokenSchema.test.ts +0 -88
- package/src/schemas/fontWeightValue.test.ts +0 -17
- package/src/schemas/numberTokenSchema.test.ts +0 -82
- package/src/schemas/referenceValueSchema.test.ts +0 -20
- package/src/schemas/schema.test.ts +0 -33
- package/src/schemas/scopeTokenSchema.test.ts +0 -29
- package/src/schemas/shadowTokenSchema.test.ts +0 -163
- package/src/schemas/stringTokenSchema.test.ts +0 -81
- package/src/schemas/tokenNameSchema.test.ts +0 -33
- package/src/schemas/typographyTokenSchema.test.ts +0 -58
- package/src/schemas/validTokenTypeSchema.test.ts +0 -32
- package/src/schemas/viewportRangeTokenSchema.test.ts +0 -59
- package/src/transformers/borderToCss.test.ts +0 -58
- package/src/transformers/colorToHex.test.ts +0 -27
- package/src/transformers/colorToHexAlpha.test.ts +0 -30
- package/src/transformers/colorToHexMix.test.ts +0 -83
- package/src/transformers/colorToRgbAlpha.test.ts +0 -33
- package/src/transformers/colorToRgbaFloat.test.ts +0 -168
- package/src/transformers/dimensionToPixelUnitless.test.ts +0 -93
- package/src/transformers/dimensionToRem.test.ts +0 -81
- package/src/transformers/durationToCss.test.ts +0 -56
- package/src/transformers/fontFamilyToCss.test.ts +0 -71
- package/src/transformers/fontWeightToNumbers.test.ts +0 -117
- package/src/transformers/jsonDeprecated.test.ts +0 -31
- package/src/transformers/namePathToCamelCase.test.ts +0 -74
- package/src/transformers/namePathToDotNotation.test.ts +0 -74
- package/src/transformers/namePathToFigma.test.ts +0 -74
- package/src/transformers/namePathToKebabCase.test.ts +0 -74
- package/src/transformers/namePathToSlashNotation.test.ts +0 -74
- package/src/transformers/shadowToCss.test.ts +0 -175
- package/src/transformers/typographyToCss.test.ts +0 -164
- package/src/transformers/utilities/alpha.test.ts +0 -28
- package/src/transformers/utilities/checkRequiredTokenProperties.test.ts +0 -28
- package/src/transformers/utilities/getTokenValue.test.ts +0 -18
- package/src/transformers/utilities/hexToRgbaFloat.test.ts +0 -66
- package/src/transformers/utilities/invalidTokenError.test.ts +0 -21
- package/src/transformers/utilities/isRgbaFloat.test.ts +0 -20
- package/src/transformers/utilities/rgbaFloatToHex.test.ts +0 -16
- package/src/utilities/getFlag.test.ts +0 -31
- package/src/utilities/joinFriendly.test.ts +0 -15
- package/src/utilities/toCamelCase.test.ts +0 -27
- package/src/utilities/treeWalker.test.ts +0 -51
- package/src/utilities/upperCaseFirstCharacter.test.ts +0 -19
- package/tokens-next-private/css/base/size/size.css +0 -19
- package/tokens-next-private/css/base/typography/typography.css +0 -6
- package/tokens-next-private/css/functional/motion/motion.css +0 -5
- package/tokens-next-private/css/functional/size/border.css +0 -14
- package/tokens-next-private/css/functional/size/breakpoints.css +0 -8
- package/tokens-next-private/css/functional/size/size-coarse.css +0 -7
- package/tokens-next-private/css/functional/size/size-fine.css +0 -7
- package/tokens-next-private/css/functional/size/size.css +0 -74
- package/tokens-next-private/css/functional/size/viewport.css +0 -6
- package/tokens-next-private/css/functional/themes/dark-colorblind.css +0 -1078
- package/tokens-next-private/css/functional/themes/dark-dimmed.css +0 -1078
- package/tokens-next-private/css/functional/themes/dark-high-contrast.css +0 -1078
- package/tokens-next-private/css/functional/themes/dark-tritanopia.css +0 -1078
- package/tokens-next-private/css/functional/themes/dark.css +0 -1078
- package/tokens-next-private/css/functional/themes/light-colorblind.css +0 -1078
- package/tokens-next-private/css/functional/themes/light-high-contrast.css +0 -1078
- package/tokens-next-private/css/functional/themes/light-tritanopia.css +0 -1078
- package/tokens-next-private/css/functional/themes/light.css +0 -1078
- package/tokens-next-private/css/functional/typography/typography.css +0 -47
- package/tokens-next-private/docs/base/size/size.json +0 -427
- package/tokens-next-private/docs/base/typography/typography.json +0 -54
- package/tokens-next-private/docs/functional/motion/motion.json +0 -47
- package/tokens-next-private/docs/functional/size/border.json +0 -234
- package/tokens-next-private/docs/functional/size/breakpoints.json +0 -152
- package/tokens-next-private/docs/functional/size/size-coarse.json +0 -41
- package/tokens-next-private/docs/functional/size/size-fine.json +0 -41
- package/tokens-next-private/docs/functional/size/size.json +0 -1838
- package/tokens-next-private/docs/functional/size/viewport.json +0 -80
- package/tokens-next-private/docs/functional/themes/dark-colorblind.json +0 -16155
- package/tokens-next-private/docs/functional/themes/dark-dimmed.json +0 -16159
- package/tokens-next-private/docs/functional/themes/dark-high-contrast.json +0 -16175
- package/tokens-next-private/docs/functional/themes/dark-tritanopia.json +0 -16161
- package/tokens-next-private/docs/functional/themes/dark.json +0 -16159
- package/tokens-next-private/docs/functional/themes/light-colorblind.json +0 -16123
- package/tokens-next-private/docs/functional/themes/light-high-contrast.json +0 -16125
- package/tokens-next-private/docs/functional/themes/light-tritanopia.json +0 -16115
- package/tokens-next-private/docs/functional/themes/light.json +0 -16113
- package/tokens-next-private/docs/functional/typography/typography.json +0 -663
- package/tokens-next-private/fallbacks/base/size/size.json +0 -19
- package/tokens-next-private/fallbacks/base/typography/typography.json +0 -6
- package/tokens-next-private/fallbacks/color-fallbacks.json +0 -260
- package/tokens-next-private/fallbacks/functional/motion/motion.json +0 -5
- package/tokens-next-private/fallbacks/functional/size/border.json +0 -14
- package/tokens-next-private/fallbacks/functional/size/breakpoints.json +0 -8
- package/tokens-next-private/fallbacks/functional/size/size-coarse.json +0 -5
- package/tokens-next-private/fallbacks/functional/size/size-fine.json +0 -5
- package/tokens-next-private/fallbacks/functional/size/size.json +0 -74
- package/tokens-next-private/fallbacks/functional/size/viewport.json +0 -8
- package/tokens-next-private/fallbacks/functional/typography/typography.json +0 -47
- package/tokens-next-private/internalCss/dark-colorblind.css +0 -1648
- package/tokens-next-private/internalCss/dark-dimmed.css +0 -1648
- package/tokens-next-private/internalCss/dark-high-contrast.css +0 -1648
- package/tokens-next-private/internalCss/dark-tritanopia.css +0 -1648
- package/tokens-next-private/internalCss/dark.css +0 -1648
- package/tokens-next-private/internalCss/light-colorblind.css +0 -1648
- package/tokens-next-private/internalCss/light-high-contrast.css +0 -1648
- package/tokens-next-private/internalCss/light-tritanopia.css +0 -1648
- package/tokens-next-private/internalCss/light.css +0 -1648
- package/tokens-next-private/removed/color.json +0 -421
- package/tokens-next-private/styleLint/base/size/size.json +0 -427
- package/tokens-next-private/styleLint/base/typography/typography.json +0 -54
- package/tokens-next-private/styleLint/functional/motion/motion.json +0 -47
- package/tokens-next-private/styleLint/functional/size/border.json +0 -234
- package/tokens-next-private/styleLint/functional/size/breakpoints.json +0 -152
- package/tokens-next-private/styleLint/functional/size/size-coarse.json +0 -41
- package/tokens-next-private/styleLint/functional/size/size-fine.json +0 -41
- package/tokens-next-private/styleLint/functional/size/size.json +0 -1838
- package/tokens-next-private/styleLint/functional/size/viewport.json +0 -80
- package/tokens-next-private/styleLint/functional/themes/dark-colorblind.json +0 -16155
- package/tokens-next-private/styleLint/functional/themes/dark-dimmed.json +0 -16159
- package/tokens-next-private/styleLint/functional/themes/dark-high-contrast.json +0 -16175
- package/tokens-next-private/styleLint/functional/themes/dark-tritanopia.json +0 -16161
- package/tokens-next-private/styleLint/functional/themes/dark.json +0 -16159
- package/tokens-next-private/styleLint/functional/themes/light-colorblind.json +0 -16123
- package/tokens-next-private/styleLint/functional/themes/light-high-contrast.json +0 -16125
- package/tokens-next-private/styleLint/functional/themes/light-tritanopia.json +0 -16115
- package/tokens-next-private/styleLint/functional/themes/light.json +0 -16113
- package/tokens-next-private/styleLint/functional/typography/typography.json +0 -663
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import {shadowValue, shadowToken} from './shadowToken'
|
|
2
|
-
|
|
3
|
-
const tokenValue = {
|
|
4
|
-
color: '#000000',
|
|
5
|
-
alpha: 0.5,
|
|
6
|
-
offsetX: '4px',
|
|
7
|
-
offsetY: '4px',
|
|
8
|
-
blur: '2px',
|
|
9
|
-
spread: '2px',
|
|
10
|
-
inset: false,
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
describe('Schema: shadowValue', () => {
|
|
14
|
-
it('parses valid shadow value', () => {
|
|
15
|
-
expect(shadowValue.safeParse(tokenValue).success).toStrictEqual(true)
|
|
16
|
-
// without inset
|
|
17
|
-
expect(
|
|
18
|
-
shadowValue.safeParse({color: '#000000', alpha: 0.5, offsetX: '4px', offsetY: '4px', blur: '2px', spread: '2px'})
|
|
19
|
-
.success,
|
|
20
|
-
).toStrictEqual(true)
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
it('fails on invalid properties', () => {
|
|
24
|
-
// additional element
|
|
25
|
-
expect(
|
|
26
|
-
shadowValue.safeParse({
|
|
27
|
-
...tokenValue,
|
|
28
|
-
additional: 1000,
|
|
29
|
-
}).success,
|
|
30
|
-
).toStrictEqual(false)
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
it('fails on missing properties', () => {
|
|
34
|
-
expect(
|
|
35
|
-
shadowValue.safeParse({
|
|
36
|
-
alpha: 0.5,
|
|
37
|
-
offsetX: '4px',
|
|
38
|
-
offsetY: '4px',
|
|
39
|
-
blur: '2px',
|
|
40
|
-
spread: '2px',
|
|
41
|
-
}).success,
|
|
42
|
-
).toStrictEqual(false)
|
|
43
|
-
expect(
|
|
44
|
-
shadowValue.safeParse({
|
|
45
|
-
color: '#000000',
|
|
46
|
-
offsetX: '4px',
|
|
47
|
-
offsetY: '4px',
|
|
48
|
-
blur: '2px',
|
|
49
|
-
spread: '2px',
|
|
50
|
-
}).success,
|
|
51
|
-
).toStrictEqual(false)
|
|
52
|
-
expect(
|
|
53
|
-
shadowValue.safeParse({
|
|
54
|
-
color: '#000000',
|
|
55
|
-
alpha: 0.5,
|
|
56
|
-
offsetY: '4px',
|
|
57
|
-
blur: '2px',
|
|
58
|
-
spread: '2px',
|
|
59
|
-
}).success,
|
|
60
|
-
).toStrictEqual(false)
|
|
61
|
-
expect(
|
|
62
|
-
shadowValue.safeParse({
|
|
63
|
-
color: '#000000',
|
|
64
|
-
alpha: 0.5,
|
|
65
|
-
offsetY: '4px',
|
|
66
|
-
blur: '2px',
|
|
67
|
-
spread: '2px',
|
|
68
|
-
}).success,
|
|
69
|
-
).toStrictEqual(false)
|
|
70
|
-
expect(
|
|
71
|
-
shadowValue.safeParse({
|
|
72
|
-
color: '#000000',
|
|
73
|
-
alpha: 0.5,
|
|
74
|
-
offsetX: '4px',
|
|
75
|
-
offsetY: '4px',
|
|
76
|
-
spread: '2px',
|
|
77
|
-
}).success,
|
|
78
|
-
).toStrictEqual(false)
|
|
79
|
-
expect(
|
|
80
|
-
shadowValue.safeParse({
|
|
81
|
-
color: '#000000',
|
|
82
|
-
alpha: 0.5,
|
|
83
|
-
offsetX: '4px',
|
|
84
|
-
offsetY: '4px',
|
|
85
|
-
blur: '2px',
|
|
86
|
-
}).success,
|
|
87
|
-
).toStrictEqual(false)
|
|
88
|
-
})
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
describe('Schema: shadowToken', () => {
|
|
92
|
-
const validToken = {
|
|
93
|
-
$value: tokenValue,
|
|
94
|
-
$type: 'shadow',
|
|
95
|
-
$description: 'a shadowToken token',
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
it('parses valid tokens', () => {
|
|
99
|
-
expect(shadowToken.safeParse(validToken).success).toStrictEqual(true)
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
it('fails on invalid properties', () => {
|
|
103
|
-
// additional element
|
|
104
|
-
expect(
|
|
105
|
-
shadowValue.safeParse({
|
|
106
|
-
...validToken,
|
|
107
|
-
additional: 1000,
|
|
108
|
-
}).success,
|
|
109
|
-
).toStrictEqual(false)
|
|
110
|
-
// missing value
|
|
111
|
-
expect(
|
|
112
|
-
shadowValue.safeParse({
|
|
113
|
-
$type: 'shadow',
|
|
114
|
-
}).success,
|
|
115
|
-
).toStrictEqual(false)
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
it('fails on wrong type', () => {
|
|
119
|
-
expect(
|
|
120
|
-
shadowToken.safeParse({
|
|
121
|
-
...validToken,
|
|
122
|
-
$type: 'motion',
|
|
123
|
-
}).success,
|
|
124
|
-
).toStrictEqual(false)
|
|
125
|
-
// undefined
|
|
126
|
-
expect(
|
|
127
|
-
shadowToken.safeParse({
|
|
128
|
-
...validToken,
|
|
129
|
-
$type: undefined,
|
|
130
|
-
}).success,
|
|
131
|
-
).toStrictEqual(false)
|
|
132
|
-
// no type
|
|
133
|
-
expect(
|
|
134
|
-
shadowToken.safeParse({
|
|
135
|
-
$value: tokenValue,
|
|
136
|
-
}).success,
|
|
137
|
-
).toStrictEqual(false)
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
it('fails on wrong value', () => {
|
|
141
|
-
// invalid string
|
|
142
|
-
expect(
|
|
143
|
-
shadowValue.safeParse({
|
|
144
|
-
...validToken,
|
|
145
|
-
$value: 100,
|
|
146
|
-
}).success,
|
|
147
|
-
).toStrictEqual(false)
|
|
148
|
-
// undefined
|
|
149
|
-
expect(
|
|
150
|
-
shadowValue.safeParse({
|
|
151
|
-
...validToken,
|
|
152
|
-
$value: undefined,
|
|
153
|
-
}).success,
|
|
154
|
-
).toStrictEqual(false)
|
|
155
|
-
// false
|
|
156
|
-
expect(
|
|
157
|
-
shadowValue.safeParse({
|
|
158
|
-
...validToken,
|
|
159
|
-
$value: false,
|
|
160
|
-
}).success,
|
|
161
|
-
).toStrictEqual(false)
|
|
162
|
-
})
|
|
163
|
-
})
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import {stringToken} from './stringToken'
|
|
2
|
-
|
|
3
|
-
describe('Schema: stringToken', () => {
|
|
4
|
-
const validToken = {
|
|
5
|
-
$value: 'a string',
|
|
6
|
-
$type: 'string',
|
|
7
|
-
$description: 'a string token',
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
it('parses valid string tokens', () => {
|
|
11
|
-
expect(stringToken.safeParse(validToken).success).toStrictEqual(true)
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
it('fails on invalid properties', () => {
|
|
15
|
-
// additional element
|
|
16
|
-
expect(
|
|
17
|
-
stringToken.safeParse({
|
|
18
|
-
...validToken,
|
|
19
|
-
additional: 1000,
|
|
20
|
-
}).success,
|
|
21
|
-
).toStrictEqual(false)
|
|
22
|
-
// missing value
|
|
23
|
-
expect(
|
|
24
|
-
stringToken.safeParse({
|
|
25
|
-
$type: 'string',
|
|
26
|
-
}).success,
|
|
27
|
-
).toStrictEqual(false)
|
|
28
|
-
// missing type
|
|
29
|
-
expect(
|
|
30
|
-
stringToken.safeParse({
|
|
31
|
-
$value: 'a string',
|
|
32
|
-
}).success,
|
|
33
|
-
).toStrictEqual(false)
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
it('fails on wrong type', () => {
|
|
37
|
-
expect(
|
|
38
|
-
stringToken.safeParse({
|
|
39
|
-
...validToken,
|
|
40
|
-
$type: 'motion',
|
|
41
|
-
}).success,
|
|
42
|
-
).toStrictEqual(false)
|
|
43
|
-
// undefined
|
|
44
|
-
expect(
|
|
45
|
-
stringToken.safeParse({
|
|
46
|
-
...validToken,
|
|
47
|
-
$type: undefined,
|
|
48
|
-
}).success,
|
|
49
|
-
).toStrictEqual(false)
|
|
50
|
-
// no type
|
|
51
|
-
expect(
|
|
52
|
-
stringToken.safeParse({
|
|
53
|
-
$value: 'a string',
|
|
54
|
-
}).success,
|
|
55
|
-
).toStrictEqual(false)
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
it('fails on wrong value', () => {
|
|
59
|
-
// invalid string
|
|
60
|
-
expect(
|
|
61
|
-
stringToken.safeParse({
|
|
62
|
-
...validToken,
|
|
63
|
-
$value: 100,
|
|
64
|
-
}).success,
|
|
65
|
-
).toStrictEqual(false)
|
|
66
|
-
// undefined
|
|
67
|
-
expect(
|
|
68
|
-
stringToken.safeParse({
|
|
69
|
-
...validToken,
|
|
70
|
-
$value: undefined,
|
|
71
|
-
}).success,
|
|
72
|
-
).toStrictEqual(false)
|
|
73
|
-
// boolean value
|
|
74
|
-
expect(
|
|
75
|
-
stringToken.safeParse({
|
|
76
|
-
...validToken,
|
|
77
|
-
$value: false,
|
|
78
|
-
}).success,
|
|
79
|
-
).toStrictEqual(false)
|
|
80
|
-
})
|
|
81
|
-
})
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import {tokenName} from './tokenName'
|
|
2
|
-
|
|
3
|
-
describe('Schema: tokenName', () => {
|
|
4
|
-
it('parses valid token names', () => {
|
|
5
|
-
expect(tokenName.safeParse('tokenname').success).toStrictEqual(true)
|
|
6
|
-
expect(tokenName.safeParse('tokenName').success).toStrictEqual(true)
|
|
7
|
-
expect(tokenName.safeParse('token-Name').success).toStrictEqual(true)
|
|
8
|
-
expect(tokenName.safeParse('token-name').success).toStrictEqual(true)
|
|
9
|
-
expect(tokenName.safeParse('10-name').success).toStrictEqual(true)
|
|
10
|
-
expect(tokenName.safeParse('token-10').success).toStrictEqual(true)
|
|
11
|
-
expect(tokenName.safeParse('@').success).toStrictEqual(true)
|
|
12
|
-
expect(tokenName.safeParse('900').success).toStrictEqual(true)
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
it('fails on invalid token names', () => {
|
|
16
|
-
expect(tokenName.safeParse('@Token').success).toStrictEqual(false)
|
|
17
|
-
expect(tokenName.safeParse('#token').success).toStrictEqual(false)
|
|
18
|
-
expect(tokenName.safeParse('token&name').success).toStrictEqual(false)
|
|
19
|
-
expect(tokenName.safeParse('token+name').success).toStrictEqual(false)
|
|
20
|
-
expect(tokenName.safeParse('token/name').success).toStrictEqual(false)
|
|
21
|
-
expect(tokenName.safeParse('Token Name').success).toStrictEqual(false)
|
|
22
|
-
expect(tokenName.safeParse('token Name').success).toStrictEqual(false)
|
|
23
|
-
expect(tokenName.safeParse('Token-Name').success).toStrictEqual(false)
|
|
24
|
-
expect(tokenName.safeParse('Token_Name').success).toStrictEqual(false)
|
|
25
|
-
expect(tokenName.safeParse('').success).toStrictEqual(false)
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
it('fails on non-string', () => {
|
|
29
|
-
expect(tokenName.safeParse(undefined).success).toStrictEqual(false)
|
|
30
|
-
expect(tokenName.safeParse(false).success).toStrictEqual(false)
|
|
31
|
-
expect(tokenName.safeParse(10).success).toStrictEqual(false)
|
|
32
|
-
})
|
|
33
|
-
})
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import {typographyToken, typographyValue} from './typographyToken'
|
|
2
|
-
|
|
3
|
-
describe('Schema: typographyToken', () => {
|
|
4
|
-
const validValue = {
|
|
5
|
-
fontSize: '16px',
|
|
6
|
-
lineHeight: '24px',
|
|
7
|
-
fontWeight: 600,
|
|
8
|
-
fontFamily: 'Helvetica',
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const validToken = {
|
|
12
|
-
$value: validValue,
|
|
13
|
-
$type: 'typography',
|
|
14
|
-
$description: 'a typography token',
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
it('parses valid tokens', () => {
|
|
18
|
-
expect(typographyToken.safeParse(validToken).success).toStrictEqual(true)
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
it('parses valid value', () => {
|
|
22
|
-
expect(typographyValue.safeParse(validValue).success).toStrictEqual(true)
|
|
23
|
-
// lineHeight is optional
|
|
24
|
-
expect(typographyValue.safeParse({...validValue, lineHeight: undefined}).success).toStrictEqual(true)
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
it('it fails on missing property', () => {
|
|
28
|
-
expect(typographyValue.safeParse({...validValue, fontSize: undefined}).success).toStrictEqual(false)
|
|
29
|
-
expect(typographyValue.safeParse({...validValue, fontWeight: undefined}).success).toStrictEqual(false)
|
|
30
|
-
expect(typographyValue.safeParse({...validValue, fontFamily: undefined}).success).toStrictEqual(false)
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
it('it fails on invalid fontSize values', () => {
|
|
34
|
-
expect(typographyValue.safeParse({...validValue, fontSize: '100%'}).success).toStrictEqual(false)
|
|
35
|
-
expect(typographyValue.safeParse({...validValue, fontSize: '100'}).success).toStrictEqual(false)
|
|
36
|
-
expect(typographyValue.safeParse({...validValue, fontSize: ''}).success).toStrictEqual(false)
|
|
37
|
-
expect(typographyValue.safeParse({...validValue, fontSize: 10}).success).toStrictEqual(false)
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
it('it fails on invalid lineHeight values', () => {
|
|
41
|
-
expect(typographyValue.safeParse({...validValue, lineHeight: '100%'}).success).toStrictEqual(false)
|
|
42
|
-
expect(typographyValue.safeParse({...validValue, lineHeight: '100'}).success).toStrictEqual(false)
|
|
43
|
-
expect(typographyValue.safeParse({...validValue, lineHeight: ''}).success).toStrictEqual(false)
|
|
44
|
-
expect(typographyValue.safeParse({...validValue, lineHeight: 10}).success).toStrictEqual(false)
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
it('it fails on invalid fontWeight values', () => {
|
|
48
|
-
expect(typographyValue.safeParse({...validValue, fontWeight: '600'}).success).toStrictEqual(false)
|
|
49
|
-
expect(typographyValue.safeParse({...validValue, fontWeight: 'bold'}).success).toStrictEqual(false)
|
|
50
|
-
expect(typographyValue.safeParse({...validValue, fontWeight: ''}).success).toStrictEqual(false)
|
|
51
|
-
expect(typographyValue.safeParse({...validValue, fontWeight: 10}).success).toStrictEqual(false)
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
it('it fails on invalid fontFamily values', () => {
|
|
55
|
-
expect(typographyValue.safeParse({...validValue, fontFamily: ''}).success).toStrictEqual(false)
|
|
56
|
-
expect(typographyValue.safeParse({...validValue, fontFamily: 10}).success).toStrictEqual(false)
|
|
57
|
-
})
|
|
58
|
-
})
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import {validateType} from './validTokenType'
|
|
2
|
-
|
|
3
|
-
const token = (type: string) => ({
|
|
4
|
-
tokenName: {$value: 1, $type: type},
|
|
5
|
-
})
|
|
6
|
-
|
|
7
|
-
describe('Schema: validateType', () => {
|
|
8
|
-
it('parses valid token types', () => {
|
|
9
|
-
expect(validateType.safeParse(token('color')).success).toStrictEqual(true)
|
|
10
|
-
expect(validateType.safeParse(token('typography')).success).toStrictEqual(true)
|
|
11
|
-
expect(validateType.safeParse(token('dimension')).success).toStrictEqual(true)
|
|
12
|
-
expect(validateType.safeParse(token('duration')).success).toStrictEqual(true)
|
|
13
|
-
expect(validateType.safeParse(token('border')).success).toStrictEqual(true)
|
|
14
|
-
expect(validateType.safeParse(token('shadow')).success).toStrictEqual(true)
|
|
15
|
-
expect(validateType.safeParse(token('fontFamily')).success).toStrictEqual(true)
|
|
16
|
-
expect(validateType.safeParse(token('fontWeight')).success).toStrictEqual(true)
|
|
17
|
-
expect(validateType.safeParse(token('number')).success).toStrictEqual(true)
|
|
18
|
-
expect(validateType.safeParse(token('string')).success).toStrictEqual(true)
|
|
19
|
-
expect(validateType.safeParse(token('custom-viewportRange')).success).toStrictEqual(true)
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
it('fails on invalid token types', () => {
|
|
23
|
-
expect(validateType.safeParse(token('invalid')).success).toStrictEqual(false)
|
|
24
|
-
expect(validateType.safeParse(token('')).success).toStrictEqual(false)
|
|
25
|
-
// @ts-expect-error: needed for test case
|
|
26
|
-
expect(validateType.safeParse(token(0)).success).toStrictEqual(false)
|
|
27
|
-
// @ts-expect-error: needed for test case
|
|
28
|
-
expect(validateType.safeParse(token(undefined)).success).toStrictEqual(false)
|
|
29
|
-
// @ts-expect-error: needed for test case
|
|
30
|
-
expect(validateType.safeParse(token(false)).success).toStrictEqual(false)
|
|
31
|
-
})
|
|
32
|
-
})
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import {viewportRangeToken} from './viewportRangeToken'
|
|
2
|
-
|
|
3
|
-
describe('Schema: viewportRangeToken', () => {
|
|
4
|
-
const validToken = {
|
|
5
|
-
$value: '(max-width: calc({<namespace>.breakpoint.medium} - 0.02px))',
|
|
6
|
-
$type: 'custom-viewportRange',
|
|
7
|
-
$description: 'a number token',
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
it('parses valid number tokens', () => {
|
|
11
|
-
expect(viewportRangeToken.safeParse(validToken).success).toStrictEqual(true)
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
it('fails on invalid properties', () => {
|
|
15
|
-
// additional element
|
|
16
|
-
expect(
|
|
17
|
-
viewportRangeToken.safeParse({
|
|
18
|
-
...validToken,
|
|
19
|
-
additional: 1000,
|
|
20
|
-
}).success,
|
|
21
|
-
).toStrictEqual(false)
|
|
22
|
-
// invalid value
|
|
23
|
-
expect(
|
|
24
|
-
viewportRangeToken.safeParse({
|
|
25
|
-
...validToken,
|
|
26
|
-
value: 1000,
|
|
27
|
-
}).success,
|
|
28
|
-
).toStrictEqual(false)
|
|
29
|
-
// missing value
|
|
30
|
-
expect(
|
|
31
|
-
viewportRangeToken.safeParse({
|
|
32
|
-
$type: 'number',
|
|
33
|
-
}).success,
|
|
34
|
-
).toStrictEqual(false)
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
it('fails on wrong type', () => {
|
|
38
|
-
// invalid string
|
|
39
|
-
expect(
|
|
40
|
-
viewportRangeToken.safeParse({
|
|
41
|
-
...validToken,
|
|
42
|
-
$type: 'motion',
|
|
43
|
-
}).success,
|
|
44
|
-
).toStrictEqual(false)
|
|
45
|
-
// undefined
|
|
46
|
-
expect(
|
|
47
|
-
viewportRangeToken.safeParse({
|
|
48
|
-
...validToken,
|
|
49
|
-
$type: undefined,
|
|
50
|
-
}).success,
|
|
51
|
-
).toStrictEqual(false)
|
|
52
|
-
// no type
|
|
53
|
-
expect(
|
|
54
|
-
viewportRangeToken.safeParse({
|
|
55
|
-
$value: '(max-width: calc({<namespace>.breakpoint.medium} - 0.02px))',
|
|
56
|
-
}).success,
|
|
57
|
-
).toStrictEqual(false)
|
|
58
|
-
})
|
|
59
|
-
})
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import {getMockToken} from '../test-utilities'
|
|
2
|
-
import {borderToCss} from './borderToCss'
|
|
3
|
-
|
|
4
|
-
describe('Transformer: borderToCss', () => {
|
|
5
|
-
it('transforms `border` token to css border string', () => {
|
|
6
|
-
const input = getMockToken({
|
|
7
|
-
value: {
|
|
8
|
-
color: '#000000',
|
|
9
|
-
style: 'solid',
|
|
10
|
-
width: '1px',
|
|
11
|
-
},
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
const expectedOutput = '#000000 solid 1px'
|
|
15
|
-
expect(borderToCss.transformer(input, {})).toStrictEqual(expectedOutput)
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
it('throws an error when required values are missing', () => {
|
|
19
|
-
// missing blur
|
|
20
|
-
expect(() =>
|
|
21
|
-
borderToCss.transformer(
|
|
22
|
-
getMockToken({
|
|
23
|
-
value: {
|
|
24
|
-
color: '#000000',
|
|
25
|
-
style: 'solid',
|
|
26
|
-
},
|
|
27
|
-
}),
|
|
28
|
-
{},
|
|
29
|
-
),
|
|
30
|
-
).toThrowError()
|
|
31
|
-
|
|
32
|
-
// missing spread
|
|
33
|
-
expect(() =>
|
|
34
|
-
borderToCss.transformer(
|
|
35
|
-
getMockToken({
|
|
36
|
-
value: {
|
|
37
|
-
color: '#000000',
|
|
38
|
-
width: '1px',
|
|
39
|
-
},
|
|
40
|
-
}),
|
|
41
|
-
{},
|
|
42
|
-
),
|
|
43
|
-
).toThrowError()
|
|
44
|
-
|
|
45
|
-
// missing offsets
|
|
46
|
-
expect(() =>
|
|
47
|
-
borderToCss.transformer(
|
|
48
|
-
getMockToken({
|
|
49
|
-
value: {
|
|
50
|
-
style: 'solid',
|
|
51
|
-
width: '1px',
|
|
52
|
-
},
|
|
53
|
-
}),
|
|
54
|
-
{},
|
|
55
|
-
),
|
|
56
|
-
).toThrowError()
|
|
57
|
-
})
|
|
58
|
-
})
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import {getMockToken} from '../test-utilities'
|
|
2
|
-
import {colorToHex} from './colorToHex'
|
|
3
|
-
|
|
4
|
-
describe('Transformer: colorToHex', () => {
|
|
5
|
-
it('transforms `hex3`, `hex6`, and `hex8` tokens to hex value', () => {
|
|
6
|
-
const input = [getMockToken({value: '#123'}), getMockToken({value: '#343434'}), getMockToken({value: '#34343466'})]
|
|
7
|
-
const expectedOutput = ['#112233', '#343434', '#34343466']
|
|
8
|
-
expect(input.map(item => colorToHex.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
it('transforms `rgb` and `rgba` to hex value', () => {
|
|
12
|
-
const input = [getMockToken({value: 'rgb(100,200,255)'}), getMockToken({value: 'rgba(100,200,255, .4)'})]
|
|
13
|
-
const expectedOutput = ['#64c8ff', '#64c8ff66']
|
|
14
|
-
expect(input.map(item => colorToHex.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
it('transforms `color` tokens and ignores alpha value', () => {
|
|
18
|
-
expect(
|
|
19
|
-
[
|
|
20
|
-
getMockToken({value: '#343434', alpha: 0.4}),
|
|
21
|
-
getMockToken({value: '#34343466', alpha: 0.9}),
|
|
22
|
-
getMockToken({value: 'rgb(100,200,255)', alpha: 0.4}),
|
|
23
|
-
getMockToken({value: 'rgba(100,200,255,0.8)', alpha: 0.4}),
|
|
24
|
-
].map(item => colorToHex.transformer(item, {})),
|
|
25
|
-
).toStrictEqual(['#343434', '#34343466', '#64c8ff', '#64c8ffcc'])
|
|
26
|
-
})
|
|
27
|
-
})
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import {getMockToken} from '../test-utilities'
|
|
2
|
-
import {colorToHexAlpha} from './colorToHexAlpha'
|
|
3
|
-
|
|
4
|
-
describe('Transformer: colorToHexAlpha', () => {
|
|
5
|
-
it('transforms hex3, hex6 `color` tokens with alpha value', () => {
|
|
6
|
-
const input = [getMockToken({value: '#123', alpha: 0.2}), getMockToken({value: '#343434', alpha: 0.4})]
|
|
7
|
-
const expectedOutput = ['#11223333', '#34343466']
|
|
8
|
-
expect(input.map(item => colorToHexAlpha.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
it('transforms hex8 `color` tokens with alpha value, ignoring the initial alpha from the hex8', () => {
|
|
12
|
-
const input = getMockToken({value: '#34343466', alpha: 0.6})
|
|
13
|
-
expect(colorToHexAlpha.transformer(input, {})).toStrictEqual('#34343499')
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
it('transforms rgb `color` tokens with alpha value', () => {
|
|
17
|
-
const input = getMockToken({value: 'rgb(100,200,255)', alpha: 0.6})
|
|
18
|
-
expect(colorToHexAlpha.transformer(input, {})).toStrictEqual('#64c8ff99')
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
it('transforms rgba `color` tokens with alpha value, ignoring the initial alpha from the hex8', () => {
|
|
22
|
-
const input = getMockToken({value: 'rgba(100,200,255, 0.2)', alpha: 0.6})
|
|
23
|
-
expect(colorToHexAlpha.transformer(input, {})).toStrictEqual('#64c8ff99')
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
it('transforms rgba `color` tokens with alpha null, ignoring alpha', () => {
|
|
27
|
-
const input = getMockToken({value: 'rgba(100,200,255, 0.5)', alpha: null})
|
|
28
|
-
expect(colorToHexAlpha.transformer(input, {})).toStrictEqual('#64c8ff80')
|
|
29
|
-
})
|
|
30
|
-
})
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import {getMockToken} from '../test-utilities'
|
|
2
|
-
import {colorToHexMix} from './colorToHexMix'
|
|
3
|
-
|
|
4
|
-
describe('Transformer: colorToHexMix', () => {
|
|
5
|
-
it('transforms hex3, hex6 `color` tokens with mix', () => {
|
|
6
|
-
const input = [
|
|
7
|
-
getMockToken({
|
|
8
|
-
value: '#567',
|
|
9
|
-
mix: {
|
|
10
|
-
color: '#000',
|
|
11
|
-
weight: 0.5,
|
|
12
|
-
},
|
|
13
|
-
}),
|
|
14
|
-
getMockToken({
|
|
15
|
-
value: '#556677',
|
|
16
|
-
mix: {
|
|
17
|
-
color: '#000',
|
|
18
|
-
weight: 0.5,
|
|
19
|
-
},
|
|
20
|
-
}),
|
|
21
|
-
]
|
|
22
|
-
const expectedOutput = ['#2b333c', '#2b333c']
|
|
23
|
-
expect(input.map(item => colorToHexMix.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
it('transforms color with mix but ignores alpha property of token', () => {
|
|
27
|
-
const input = [
|
|
28
|
-
getMockToken({
|
|
29
|
-
value: '#556677',
|
|
30
|
-
alpha: 0.4,
|
|
31
|
-
mix: {
|
|
32
|
-
color: '#000',
|
|
33
|
-
weight: 0.2,
|
|
34
|
-
},
|
|
35
|
-
}),
|
|
36
|
-
]
|
|
37
|
-
const expectedOutput = ['#44525f']
|
|
38
|
-
expect(input.map(item => colorToHexMix.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
it('transforms color with mix and merges alpha from hex8', () => {
|
|
42
|
-
const input = [
|
|
43
|
-
getMockToken({
|
|
44
|
-
value: '#55667755',
|
|
45
|
-
mix: {
|
|
46
|
-
color: '#000',
|
|
47
|
-
weight: 0.2,
|
|
48
|
-
},
|
|
49
|
-
}),
|
|
50
|
-
getMockToken({
|
|
51
|
-
value: '#55667755',
|
|
52
|
-
mix: {
|
|
53
|
-
color: '#00000022',
|
|
54
|
-
weight: 0.2,
|
|
55
|
-
},
|
|
56
|
-
}),
|
|
57
|
-
]
|
|
58
|
-
const expectedOutput = ['#51617177', '#3e4a574b']
|
|
59
|
-
expect(input.map(item => colorToHexMix.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
it('ignore mix if undefined or weight or color is undefined', () => {
|
|
63
|
-
const input = [
|
|
64
|
-
getMockToken({
|
|
65
|
-
value: '#556677',
|
|
66
|
-
}),
|
|
67
|
-
getMockToken({
|
|
68
|
-
value: '#556677',
|
|
69
|
-
mix: {
|
|
70
|
-
weight: 0.2,
|
|
71
|
-
},
|
|
72
|
-
}),
|
|
73
|
-
getMockToken({
|
|
74
|
-
value: '#556677',
|
|
75
|
-
mix: {
|
|
76
|
-
color: '#000000',
|
|
77
|
-
},
|
|
78
|
-
}),
|
|
79
|
-
]
|
|
80
|
-
const expectedOutput = ['#556677', '#556677', '#556677']
|
|
81
|
-
expect(input.map(item => colorToHexMix.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
82
|
-
})
|
|
83
|
-
})
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import {getMockToken} from '../test-utilities'
|
|
2
|
-
import {colorToRgbAlpha} from './colorToRgbAlpha'
|
|
3
|
-
|
|
4
|
-
describe('Transformer: colorToRgbAlpha', () => {
|
|
5
|
-
it('transforms hex3, hex6 `color` tokens with alpha value', () => {
|
|
6
|
-
const input = [getMockToken({value: '#123', alpha: 0.2}), getMockToken({value: '#343434', alpha: 0.4})]
|
|
7
|
-
const expectedOutput = ['rgba(17, 34, 51, 0.2)', 'rgba(52, 52, 52, 0.4)']
|
|
8
|
-
expect(input.map(item => colorToRgbAlpha.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
it('transforms hex8 `color` tokens with alpha value, ignoring the initial alpha from the hex8', () => {
|
|
12
|
-
const input = getMockToken({value: '#34343466', alpha: 0.6})
|
|
13
|
-
const expectedOutput = 'rgba(52, 52, 52, 0.6)'
|
|
14
|
-
expect(colorToRgbAlpha.transformer(input, {})).toStrictEqual(expectedOutput)
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
it('transforms rgb `color` tokens with alpha value', () => {
|
|
18
|
-
const input = getMockToken({value: 'rgb(100,200,255)', alpha: 0.6})
|
|
19
|
-
const expectedOutput = 'rgba(100, 200, 255, 0.6)'
|
|
20
|
-
expect(colorToRgbAlpha.transformer(input, {})).toStrictEqual(expectedOutput)
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
it('transforms rgba `color` tokens with alpha value, ignoring the initial alpha from the hex8', () => {
|
|
24
|
-
const input = getMockToken({value: 'rgba(100,200,255, 0.2)', alpha: 0.6})
|
|
25
|
-
const expectedOutput = 'rgba(100, 200, 255, 0.6)'
|
|
26
|
-
expect(colorToRgbAlpha.transformer(input, {})).toStrictEqual(expectedOutput)
|
|
27
|
-
})
|
|
28
|
-
it('transforms rgba `color` tokens with alpha null, ignoring alpha', () => {
|
|
29
|
-
const input = getMockToken({value: 'rgba(100,200,255, 0.5)', alpha: null})
|
|
30
|
-
const expectedOutput = 'rgba(100,200,255, 0.5)'
|
|
31
|
-
expect(colorToRgbAlpha.transformer(input, {})).toStrictEqual(expectedOutput)
|
|
32
|
-
})
|
|
33
|
-
})
|