@primer/primitives 7.17.0-rc.61b28bca → 7.17.0-rc.8ff6ed39
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 +2 -3
- 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/dist/deprecated/colors.json +0 -7
- package/dist/js/colors/dark.d.ts +0 -516
- package/dist/js/colors/dark.js +0 -616
- package/dist/js/colors/dark_colorblind.d.ts +0 -516
- package/dist/js/colors/dark_colorblind.js +0 -616
- package/dist/js/colors/dark_dimmed.d.ts +0 -516
- package/dist/js/colors/dark_dimmed.js +0 -616
- package/dist/js/colors/dark_high_contrast.d.ts +0 -516
- package/dist/js/colors/dark_high_contrast.js +0 -616
- package/dist/js/colors/dark_tritanopia.d.ts +0 -516
- package/dist/js/colors/dark_tritanopia.js +0 -616
- package/dist/js/colors/index.d.ts +0 -4638
- package/dist/js/colors/index.js +0 -15
- package/dist/js/colors/light.d.ts +0 -516
- package/dist/js/colors/light.js +0 -616
- package/dist/js/colors/light_colorblind.d.ts +0 -516
- package/dist/js/colors/light_colorblind.js +0 -616
- package/dist/js/colors/light_high_contrast.d.ts +0 -516
- package/dist/js/colors/light_high_contrast.js +0 -616
- package/dist/js/colors/light_tritanopia.d.ts +0 -516
- package/dist/js/colors/light_tritanopia.js +0 -616
- package/dist/js/index.d.ts +0 -4655
- package/dist/js/index.js +0 -9
- package/dist/js/spacing/index.d.ts +0 -6
- package/dist/js/spacing/index.js +0 -7
- package/dist/js/spacing/normal.d.ts +0 -4
- package/dist/js/spacing/normal.js +0 -13
- package/dist/js/typography/index.d.ts +0 -11
- package/dist/js/typography/index.js +0 -7
- package/dist/js/typography/normal.d.ts +0 -9
- package/dist/js/typography/normal.js +0 -19
- package/dist/json/colors/dark.json +0 -614
- package/dist/json/colors/dark_colorblind.json +0 -614
- package/dist/json/colors/dark_dimmed.json +0 -614
- package/dist/json/colors/dark_high_contrast.json +0 -614
- package/dist/json/colors/dark_tritanopia.json +0 -614
- package/dist/json/colors/light.json +0 -614
- package/dist/json/colors/light_colorblind.json +0 -614
- package/dist/json/colors/light_high_contrast.json +0 -614
- package/dist/json/colors/light_tritanopia.json +0 -614
- package/dist/json/spacing/normal.json +0 -11
- package/dist/json/typography/normal.json +0 -17
- package/dist/removed/colors.json +0 -432
- package/dist/scss/colors/_dark.scss +0 -452
- package/dist/scss/colors/_dark_colorblind.scss +0 -452
- package/dist/scss/colors/_dark_dimmed.scss +0 -452
- package/dist/scss/colors/_dark_high_contrast.scss +0 -452
- package/dist/scss/colors/_dark_tritanopia.scss +0 -452
- package/dist/scss/colors/_light.scss +0 -452
- package/dist/scss/colors/_light_colorblind.scss +0 -452
- package/dist/scss/colors/_light_high_contrast.scss +0 -452
- package/dist/scss/colors/_light_tritanopia.scss +0 -452
- package/dist/scss/spacing/_normal.scss +0 -11
- package/dist/scss/typography/_normal.scss +0 -15
- package/dist/ts/colors/dark.ts +0 -614
- package/dist/ts/colors/dark_colorblind.ts +0 -614
- package/dist/ts/colors/dark_dimmed.ts +0 -614
- package/dist/ts/colors/dark_high_contrast.ts +0 -614
- package/dist/ts/colors/dark_tritanopia.ts +0 -614
- package/dist/ts/colors/index.ts +0 -10
- package/dist/ts/colors/light.ts +0 -614
- package/dist/ts/colors/light_colorblind.ts +0 -614
- package/dist/ts/colors/light_high_contrast.ts +0 -614
- package/dist/ts/colors/light_tritanopia.ts +0 -614
- package/dist/ts/index.ts +0 -4
- package/dist/ts/spacing/index.ts +0 -2
- package/dist/ts/spacing/normal.ts +0 -11
- package/dist/ts/typography/index.ts +0 -2
- package/dist/ts/typography/normal.ts +0 -17
- 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,168 +0,0 @@
|
|
|
1
|
-
import {getMockToken} from '../test-utilities'
|
|
2
|
-
import {colorToRgbaFloat} from './colorToRgbaFloat'
|
|
3
|
-
import {rgbaFloatToHex} from './utilities/rgbaFloatToHex'
|
|
4
|
-
|
|
5
|
-
describe('Transformer: colorToRgbaFloat', () => {
|
|
6
|
-
it('transforms `hex3`, `hex6`, and `hex8` tokens to rgb float value', () => {
|
|
7
|
-
const input = [getMockToken({value: '#123'}), getMockToken({value: '#343434'}), getMockToken({value: '#34343466'})]
|
|
8
|
-
const expectedOutput = [
|
|
9
|
-
{
|
|
10
|
-
r: 0.06666666666666667,
|
|
11
|
-
g: 0.13333333333333333,
|
|
12
|
-
b: 0.2,
|
|
13
|
-
a: 1,
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
r: 0.20392156862745098,
|
|
17
|
-
g: 0.20392156862745098,
|
|
18
|
-
b: 0.20392156862745098,
|
|
19
|
-
a: 1,
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
r: 0.20392156862745098,
|
|
23
|
-
g: 0.20392156862745098,
|
|
24
|
-
b: 0.20392156862745098,
|
|
25
|
-
a: 0.4,
|
|
26
|
-
},
|
|
27
|
-
]
|
|
28
|
-
expect(input.map(item => colorToRgbaFloat.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
it('transforms `rgb` and `rgba` to rgb float value', () => {
|
|
32
|
-
const input = [getMockToken({value: 'rgb(100,200,255)'}), getMockToken({value: 'rgba(100,200,255, .4)'})]
|
|
33
|
-
const expectedOutput = [
|
|
34
|
-
{
|
|
35
|
-
r: 0.39215686274509803,
|
|
36
|
-
g: 0.7843137254901961,
|
|
37
|
-
b: 1,
|
|
38
|
-
a: 1,
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
r: 0.39215686274509803,
|
|
42
|
-
g: 0.7843137254901961,
|
|
43
|
-
b: 1,
|
|
44
|
-
a: 0.4,
|
|
45
|
-
},
|
|
46
|
-
]
|
|
47
|
-
expect(input.map(item => colorToRgbaFloat.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
it('transforms `color` tokens including alpha value', () => {
|
|
51
|
-
expect(
|
|
52
|
-
[
|
|
53
|
-
getMockToken({value: '#343434', alpha: 0.4}),
|
|
54
|
-
getMockToken({value: '#34343466', alpha: 0.9}),
|
|
55
|
-
getMockToken({value: 'rgb(100,200,255)', alpha: 0.4}),
|
|
56
|
-
getMockToken({value: 'rgba(100,200,255,0.8)', alpha: 0.4}),
|
|
57
|
-
].map(item => colorToRgbaFloat.transformer(item, {})),
|
|
58
|
-
).toStrictEqual([
|
|
59
|
-
{
|
|
60
|
-
r: 0.20392156862745098,
|
|
61
|
-
g: 0.20392156862745098,
|
|
62
|
-
b: 0.20392156862745098,
|
|
63
|
-
a: 0.4,
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
r: 0.20392156862745098,
|
|
67
|
-
g: 0.20392156862745098,
|
|
68
|
-
b: 0.20392156862745098,
|
|
69
|
-
a: 0.9,
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
r: 0.39215686274509803,
|
|
73
|
-
g: 0.7843137254901961,
|
|
74
|
-
b: 1,
|
|
75
|
-
a: 0.4,
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
r: 0.39215686274509803,
|
|
79
|
-
g: 0.7843137254901961,
|
|
80
|
-
b: 1,
|
|
81
|
-
a: 0.4,
|
|
82
|
-
},
|
|
83
|
-
])
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
it('transforms `color` tokens including mix', () => {
|
|
87
|
-
expect(
|
|
88
|
-
[
|
|
89
|
-
getMockToken({name: 'Mix of reds', value: '#a40e26', mix: {color: '#660018', weight: 0.4}}),
|
|
90
|
-
getMockToken({value: '#34343466', mix: {color: '#000000'}}),
|
|
91
|
-
getMockToken({value: 'rgb(100,200,255)', mix: {weight: 0.5}}),
|
|
92
|
-
getMockToken({value: 'rgba(100,200,255,0.8)', mix: {color: undefined, weight: undefined}}),
|
|
93
|
-
].map(item => colorToRgbaFloat.transformer(item, {})),
|
|
94
|
-
).toStrictEqual([
|
|
95
|
-
{
|
|
96
|
-
b: 0.12549019607843137,
|
|
97
|
-
g: 0.03137254901960784,
|
|
98
|
-
r: 0.5450980392156862,
|
|
99
|
-
a: 1,
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
r: 0.20392156862745098,
|
|
103
|
-
g: 0.20392156862745098,
|
|
104
|
-
b: 0.20392156862745098,
|
|
105
|
-
a: 0.4,
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
r: 0.39215686274509803,
|
|
109
|
-
g: 0.7843137254901961,
|
|
110
|
-
b: 1,
|
|
111
|
-
a: 1,
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
r: 0.39215686274509803,
|
|
115
|
-
g: 0.7843137254901961,
|
|
116
|
-
b: 1,
|
|
117
|
-
a: 0.8,
|
|
118
|
-
},
|
|
119
|
-
])
|
|
120
|
-
|
|
121
|
-
expect(
|
|
122
|
-
[
|
|
123
|
-
getMockToken({name: 'Mix of reds', value: '#a40e26', mix: {color: '#660018', weight: 0.4}}),
|
|
124
|
-
getMockToken({value: '#34343466', mix: {color: '#000000'}}),
|
|
125
|
-
getMockToken({value: 'rgb(100,200,255)', mix: {weight: 0.5}}),
|
|
126
|
-
getMockToken({value: 'rgba(100,200,255,0.8)', mix: {color: undefined, weight: undefined}}),
|
|
127
|
-
]
|
|
128
|
-
.map(item => colorToRgbaFloat.transformer(item, {}))
|
|
129
|
-
.map(item => rgbaFloatToHex(item)),
|
|
130
|
-
).toStrictEqual(['#8b0820', '#34343466', '#64c8ff', '#64c8ffcc'])
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
it('it forwards `rgb float` values', () => {
|
|
134
|
-
const input = [
|
|
135
|
-
getMockToken({
|
|
136
|
-
value: {
|
|
137
|
-
r: 0.39215686274509803,
|
|
138
|
-
g: 0.7843137254901961,
|
|
139
|
-
b: 1,
|
|
140
|
-
a: 1,
|
|
141
|
-
},
|
|
142
|
-
}),
|
|
143
|
-
getMockToken({
|
|
144
|
-
value: {
|
|
145
|
-
r: 0.39215686274509803,
|
|
146
|
-
g: 0.7843137254901961,
|
|
147
|
-
b: 1,
|
|
148
|
-
a: 0.4,
|
|
149
|
-
},
|
|
150
|
-
}),
|
|
151
|
-
]
|
|
152
|
-
const expectedOutput = [
|
|
153
|
-
{
|
|
154
|
-
r: 0.39215686274509803,
|
|
155
|
-
g: 0.7843137254901961,
|
|
156
|
-
b: 1,
|
|
157
|
-
a: 1,
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
r: 0.39215686274509803,
|
|
161
|
-
g: 0.7843137254901961,
|
|
162
|
-
b: 1,
|
|
163
|
-
a: 0.4,
|
|
164
|
-
},
|
|
165
|
-
]
|
|
166
|
-
expect(input.map(item => colorToRgbaFloat.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
167
|
-
})
|
|
168
|
-
})
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import {getMockToken} from '../test-utilities'
|
|
2
|
-
import {dimensionToPixelUnitless} from './dimensionToPixelUnitless'
|
|
3
|
-
|
|
4
|
-
describe('Transformer: dimensionToPixelUnitless', () => {
|
|
5
|
-
it('transforms pixel string tokens', () => {
|
|
6
|
-
const input = [
|
|
7
|
-
getMockToken({
|
|
8
|
-
value: '16px',
|
|
9
|
-
}),
|
|
10
|
-
]
|
|
11
|
-
const expectedOutput = [16]
|
|
12
|
-
expect(input.map(item => dimensionToPixelUnitless.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
it('does not transforms number or number string', () => {
|
|
16
|
-
const input = [
|
|
17
|
-
getMockToken({
|
|
18
|
-
value: '16',
|
|
19
|
-
}),
|
|
20
|
-
getMockToken({
|
|
21
|
-
value: 16,
|
|
22
|
-
}),
|
|
23
|
-
]
|
|
24
|
-
const expectedOutput = ['16', 16]
|
|
25
|
-
expect(input.map(item => dimensionToPixelUnitless.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
it('transforms rem', () => {
|
|
29
|
-
const input = [
|
|
30
|
-
getMockToken({
|
|
31
|
-
value: '1rem',
|
|
32
|
-
}),
|
|
33
|
-
]
|
|
34
|
-
const expectedOutput = [16]
|
|
35
|
-
expect(input.map(item => dimensionToPixelUnitless.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
it('transforms rem with custom basePxFontSize', () => {
|
|
39
|
-
const input = [
|
|
40
|
-
getMockToken({
|
|
41
|
-
value: '2rem',
|
|
42
|
-
}),
|
|
43
|
-
]
|
|
44
|
-
const expectedOutput = [20]
|
|
45
|
-
expect(input.map(item => dimensionToPixelUnitless.transformer(item, {basePxFontSize: 10}))).toStrictEqual(
|
|
46
|
-
expectedOutput,
|
|
47
|
-
)
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
it('does not transforms em', () => {
|
|
51
|
-
const input = [
|
|
52
|
-
getMockToken({
|
|
53
|
-
value: '1em',
|
|
54
|
-
}),
|
|
55
|
-
]
|
|
56
|
-
const expectedOutput = ['1em']
|
|
57
|
-
expect(input.map(item => dimensionToPixelUnitless.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
it('transforms 0 to 0', () => {
|
|
61
|
-
const input = [
|
|
62
|
-
getMockToken({
|
|
63
|
-
value: '0rem',
|
|
64
|
-
}),
|
|
65
|
-
getMockToken({
|
|
66
|
-
value: '0px',
|
|
67
|
-
}),
|
|
68
|
-
getMockToken({
|
|
69
|
-
value: '0',
|
|
70
|
-
}),
|
|
71
|
-
]
|
|
72
|
-
const expectedOutput = [0, 0, 0]
|
|
73
|
-
expect(input.map(item => dimensionToPixelUnitless.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
it('throws on invalid tokens', () => {
|
|
77
|
-
const input = [
|
|
78
|
-
getMockToken({
|
|
79
|
-
value: 'rem',
|
|
80
|
-
}),
|
|
81
|
-
getMockToken({
|
|
82
|
-
value: '',
|
|
83
|
-
}),
|
|
84
|
-
getMockToken({
|
|
85
|
-
value: undefined,
|
|
86
|
-
}),
|
|
87
|
-
getMockToken({
|
|
88
|
-
value: null,
|
|
89
|
-
}),
|
|
90
|
-
]
|
|
91
|
-
expect(() => input.map(item => dimensionToPixelUnitless.transformer(item, {}))).toThrow()
|
|
92
|
-
})
|
|
93
|
-
})
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import {getMockToken} from '../test-utilities'
|
|
2
|
-
import {dimensionToRem} from './dimensionToRem'
|
|
3
|
-
|
|
4
|
-
describe('Transformer: dimensionToRem', () => {
|
|
5
|
-
it('transforms pixel string tokens to rem', () => {
|
|
6
|
-
const input = [
|
|
7
|
-
getMockToken({
|
|
8
|
-
value: '16px',
|
|
9
|
-
}),
|
|
10
|
-
]
|
|
11
|
-
const expectedOutput = ['1rem']
|
|
12
|
-
expect(input.map(item => dimensionToRem.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
it('transforms number to rem', () => {
|
|
16
|
-
const input = [
|
|
17
|
-
getMockToken({
|
|
18
|
-
value: '16',
|
|
19
|
-
}),
|
|
20
|
-
getMockToken({
|
|
21
|
-
value: 16,
|
|
22
|
-
}),
|
|
23
|
-
]
|
|
24
|
-
const expectedOutput = ['1rem', '1rem']
|
|
25
|
-
expect(input.map(item => dimensionToRem.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
it('transforms rem to rem', () => {
|
|
29
|
-
const input = [
|
|
30
|
-
getMockToken({
|
|
31
|
-
value: '1rem',
|
|
32
|
-
}),
|
|
33
|
-
]
|
|
34
|
-
const expectedOutput = ['1rem']
|
|
35
|
-
expect(input.map(item => dimensionToRem.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
it('does not transforms em to rem', () => {
|
|
39
|
-
const input = [
|
|
40
|
-
getMockToken({
|
|
41
|
-
value: '1em',
|
|
42
|
-
}),
|
|
43
|
-
]
|
|
44
|
-
const expectedOutput = ['1em']
|
|
45
|
-
expect(input.map(item => dimensionToRem.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
it('transforms 0 to 0', () => {
|
|
49
|
-
const input = [
|
|
50
|
-
getMockToken({
|
|
51
|
-
value: '0rem',
|
|
52
|
-
}),
|
|
53
|
-
getMockToken({
|
|
54
|
-
value: '0px',
|
|
55
|
-
}),
|
|
56
|
-
getMockToken({
|
|
57
|
-
value: '0',
|
|
58
|
-
}),
|
|
59
|
-
]
|
|
60
|
-
const expectedOutput = ['0', '0', '0']
|
|
61
|
-
expect(input.map(item => dimensionToRem.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
it('throws on invalid tokens', () => {
|
|
65
|
-
const input = [
|
|
66
|
-
getMockToken({
|
|
67
|
-
value: 'rem',
|
|
68
|
-
}),
|
|
69
|
-
getMockToken({
|
|
70
|
-
value: '',
|
|
71
|
-
}),
|
|
72
|
-
getMockToken({
|
|
73
|
-
value: undefined,
|
|
74
|
-
}),
|
|
75
|
-
getMockToken({
|
|
76
|
-
value: null,
|
|
77
|
-
}),
|
|
78
|
-
]
|
|
79
|
-
expect(() => input.map(item => dimensionToRem.transformer(item, {}))).toThrow()
|
|
80
|
-
})
|
|
81
|
-
})
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import {getMockToken} from '../test-utilities'
|
|
2
|
-
import {durationToCss} from './durationToCss'
|
|
3
|
-
|
|
4
|
-
describe('Transformer: durationToCss', () => {
|
|
5
|
-
it('transforms `duration` token to css duration', () => {
|
|
6
|
-
const input = getMockToken({
|
|
7
|
-
value: '100ms',
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
const expectedOutput = '100ms'
|
|
11
|
-
expect(durationToCss.transformer(input, {})).toStrictEqual(expectedOutput)
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
it('transforms `ms` to `s`', () => {
|
|
15
|
-
const input = getMockToken({
|
|
16
|
-
value: '1252ms',
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
const expectedOutput = '1.252s'
|
|
20
|
-
expect(durationToCss.transformer(input, {})).toStrictEqual(expectedOutput)
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
it('throws an error when unit is missing or invalid', () => {
|
|
24
|
-
// missing unit
|
|
25
|
-
expect(() =>
|
|
26
|
-
durationToCss.transformer(
|
|
27
|
-
getMockToken({
|
|
28
|
-
value: '1000',
|
|
29
|
-
}),
|
|
30
|
-
{},
|
|
31
|
-
),
|
|
32
|
-
).toThrowError()
|
|
33
|
-
|
|
34
|
-
// only ms unit is supported
|
|
35
|
-
expect(() =>
|
|
36
|
-
durationToCss.transformer(
|
|
37
|
-
getMockToken({
|
|
38
|
-
value: '1s',
|
|
39
|
-
}),
|
|
40
|
-
{},
|
|
41
|
-
),
|
|
42
|
-
).toThrowError()
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
it('throws an error when value is number', () => {
|
|
46
|
-
// missing unit
|
|
47
|
-
expect(() =>
|
|
48
|
-
durationToCss.transformer(
|
|
49
|
-
getMockToken({
|
|
50
|
-
value: 1000,
|
|
51
|
-
}),
|
|
52
|
-
{},
|
|
53
|
-
),
|
|
54
|
-
).toThrowError()
|
|
55
|
-
})
|
|
56
|
-
})
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import {getMockToken} from '../test-utilities'
|
|
2
|
-
import {fontFamilyToCss} from './fontFamilyToCss'
|
|
3
|
-
|
|
4
|
-
describe('Transformer: fontFamilyToCss', () => {
|
|
5
|
-
it('transforms fontFamily string', () => {
|
|
6
|
-
const input = [
|
|
7
|
-
getMockToken({
|
|
8
|
-
value: 'Roboto, Noto Sans',
|
|
9
|
-
}),
|
|
10
|
-
getMockToken({
|
|
11
|
-
value: 'Roboto',
|
|
12
|
-
}),
|
|
13
|
-
]
|
|
14
|
-
const expectedOutput = ['Roboto, Noto Sans', 'Roboto']
|
|
15
|
-
expect(input.map(item => fontFamilyToCss.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
it('transforms fontFamily array', () => {
|
|
19
|
-
const input = [
|
|
20
|
-
getMockToken({
|
|
21
|
-
value: ['Roboto', 'Noto Sans'],
|
|
22
|
-
}),
|
|
23
|
-
getMockToken({
|
|
24
|
-
value: ['Roboto'],
|
|
25
|
-
}),
|
|
26
|
-
]
|
|
27
|
-
const expectedOutput = ["Roboto, 'Noto Sans'", 'Roboto']
|
|
28
|
-
expect(input.map(item => fontFamilyToCss.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
it('throws on invalid value', () => {
|
|
32
|
-
expect(() =>
|
|
33
|
-
fontFamilyToCss.transformer(
|
|
34
|
-
getMockToken({
|
|
35
|
-
value: {
|
|
36
|
-
fontFamily: 'Roboto',
|
|
37
|
-
fontSize: '42px',
|
|
38
|
-
},
|
|
39
|
-
}),
|
|
40
|
-
{},
|
|
41
|
-
),
|
|
42
|
-
).toThrowError()
|
|
43
|
-
|
|
44
|
-
expect(() =>
|
|
45
|
-
fontFamilyToCss.transformer(
|
|
46
|
-
getMockToken({
|
|
47
|
-
value: 42,
|
|
48
|
-
}),
|
|
49
|
-
{},
|
|
50
|
-
),
|
|
51
|
-
).toThrowError()
|
|
52
|
-
|
|
53
|
-
expect(() =>
|
|
54
|
-
fontFamilyToCss.transformer(
|
|
55
|
-
getMockToken({
|
|
56
|
-
value: undefined,
|
|
57
|
-
}),
|
|
58
|
-
{},
|
|
59
|
-
),
|
|
60
|
-
).toThrowError()
|
|
61
|
-
|
|
62
|
-
expect(() =>
|
|
63
|
-
fontFamilyToCss.transformer(
|
|
64
|
-
getMockToken({
|
|
65
|
-
value: [42, 'Roboto'],
|
|
66
|
-
}),
|
|
67
|
-
{},
|
|
68
|
-
),
|
|
69
|
-
).toThrowError()
|
|
70
|
-
})
|
|
71
|
-
})
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import {getMockToken} from '../test-utilities'
|
|
2
|
-
import {fontWeightToNumber} from './fontWeightToNumber'
|
|
3
|
-
|
|
4
|
-
describe('Transformer: fontWeightToNumbers', () => {
|
|
5
|
-
it('keeps number if within range of 1-1000', () => {
|
|
6
|
-
const input = [
|
|
7
|
-
getMockToken({
|
|
8
|
-
value: 100,
|
|
9
|
-
}),
|
|
10
|
-
getMockToken({
|
|
11
|
-
value: 1000,
|
|
12
|
-
}),
|
|
13
|
-
]
|
|
14
|
-
const expectedOutput = [100, 1000]
|
|
15
|
-
expect(input.map(item => fontWeightToNumber.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
it('transforms string of number to number', () => {
|
|
19
|
-
const input = getMockToken({
|
|
20
|
-
value: '100',
|
|
21
|
-
})
|
|
22
|
-
const expectedOutput = 100
|
|
23
|
-
expect(fontWeightToNumber.transformer(input, {})).toStrictEqual(expectedOutput)
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
it('transforms font strings to number', () => {
|
|
27
|
-
const testCases: [fontWeightNumber: number, fontWeightString: string][] = [
|
|
28
|
-
[100, 'thin'],
|
|
29
|
-
[100, 'hairline'],
|
|
30
|
-
[200, 'extra-light'],
|
|
31
|
-
[200, 'ultra-light'],
|
|
32
|
-
[300, 'light'],
|
|
33
|
-
[400, 'normal'],
|
|
34
|
-
[400, 'regular'],
|
|
35
|
-
[400, 'book'],
|
|
36
|
-
[500, 'medium'],
|
|
37
|
-
[600, 'semi-bold'],
|
|
38
|
-
[600, 'demi-bold'],
|
|
39
|
-
[700, 'bold'],
|
|
40
|
-
[800, 'extra-bold'],
|
|
41
|
-
[800, 'ultra-bold'],
|
|
42
|
-
[900, 'black'],
|
|
43
|
-
[900, 'heavy'],
|
|
44
|
-
[950, 'extra-black'],
|
|
45
|
-
[950, 'ultra-black'],
|
|
46
|
-
]
|
|
47
|
-
|
|
48
|
-
for (const [fontWeightNumber, fontWeightString] of testCases) {
|
|
49
|
-
const input = getMockToken({
|
|
50
|
-
value: fontWeightString,
|
|
51
|
-
})
|
|
52
|
-
try {
|
|
53
|
-
expect(fontWeightToNumber.transformer(input, {})).toStrictEqual(fontWeightNumber)
|
|
54
|
-
} catch (e) {
|
|
55
|
-
throw new Error(`❌ Expects ${fontWeightString} to be transformed to ${fontWeightNumber}`)
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
it('throws on invalid value', () => {
|
|
61
|
-
expect(() =>
|
|
62
|
-
fontWeightToNumber.transformer(
|
|
63
|
-
getMockToken({
|
|
64
|
-
value: 1001,
|
|
65
|
-
}),
|
|
66
|
-
{},
|
|
67
|
-
),
|
|
68
|
-
).toThrowError()
|
|
69
|
-
|
|
70
|
-
expect(() =>
|
|
71
|
-
fontWeightToNumber.transformer(
|
|
72
|
-
getMockToken({
|
|
73
|
-
value: 0,
|
|
74
|
-
}),
|
|
75
|
-
{},
|
|
76
|
-
),
|
|
77
|
-
).toThrowError()
|
|
78
|
-
|
|
79
|
-
expect(() =>
|
|
80
|
-
fontWeightToNumber.transformer(
|
|
81
|
-
getMockToken({
|
|
82
|
-
value: undefined,
|
|
83
|
-
}),
|
|
84
|
-
{},
|
|
85
|
-
),
|
|
86
|
-
).toThrowError()
|
|
87
|
-
|
|
88
|
-
expect(() =>
|
|
89
|
-
fontWeightToNumber.transformer(
|
|
90
|
-
getMockToken({
|
|
91
|
-
value: 'Roboto',
|
|
92
|
-
}),
|
|
93
|
-
{},
|
|
94
|
-
),
|
|
95
|
-
).toThrowError()
|
|
96
|
-
|
|
97
|
-
expect(() =>
|
|
98
|
-
fontWeightToNumber.transformer(
|
|
99
|
-
getMockToken({
|
|
100
|
-
value: ['Roboto'],
|
|
101
|
-
}),
|
|
102
|
-
{},
|
|
103
|
-
),
|
|
104
|
-
).toThrowError()
|
|
105
|
-
|
|
106
|
-
expect(() =>
|
|
107
|
-
fontWeightToNumber.transformer(
|
|
108
|
-
getMockToken({
|
|
109
|
-
value: {
|
|
110
|
-
fontWeight: 300,
|
|
111
|
-
},
|
|
112
|
-
}),
|
|
113
|
-
{},
|
|
114
|
-
),
|
|
115
|
-
).toThrowError()
|
|
116
|
-
})
|
|
117
|
-
})
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import {getMockToken} from '../test-utilities'
|
|
2
|
-
import {jsonDeprecated} from './jsonDeprecated'
|
|
3
|
-
|
|
4
|
-
describe('Transformer: jsonDeprecated', () => {
|
|
5
|
-
it('Replaces token value with `null` if deprecated is set to `true`', () => {
|
|
6
|
-
const item = getMockToken({
|
|
7
|
-
value: 'tokenName',
|
|
8
|
-
deprecated: true,
|
|
9
|
-
})
|
|
10
|
-
const expectedOutput = null
|
|
11
|
-
expect(jsonDeprecated.transformer(item, {})).toStrictEqual(expectedOutput)
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
it('Replaces token value with deprecated value if deprecated is a `string`', () => {
|
|
15
|
-
const item = getMockToken({
|
|
16
|
-
value: 'tokenName',
|
|
17
|
-
deprecated: `token.pumpkin`,
|
|
18
|
-
})
|
|
19
|
-
const expectedOutput = 'token.pumpkin'
|
|
20
|
-
expect(jsonDeprecated.transformer(item, {})).toStrictEqual(expectedOutput)
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
it('Replaces token value with deprecated value if deprecated is a `string` and removes {}', () => {
|
|
24
|
-
const item = getMockToken({
|
|
25
|
-
value: 'tokenName',
|
|
26
|
-
deprecated: `{token.pumpkin}`,
|
|
27
|
-
})
|
|
28
|
-
const expectedOutput = 'token.pumpkin'
|
|
29
|
-
expect(jsonDeprecated.transformer(item, {})).toStrictEqual(expectedOutput)
|
|
30
|
-
})
|
|
31
|
-
})
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import {getMockToken} from '../test-utilities'
|
|
2
|
-
import {namePathToCamelCase} from './namePathToCamelCase'
|
|
3
|
-
|
|
4
|
-
describe('Transformer: namePathToCamelCase', () => {
|
|
5
|
-
it('converts path elements to dot.notation and ignores name proprty', () => {
|
|
6
|
-
const input = [
|
|
7
|
-
getMockToken({
|
|
8
|
-
name: 'tokenName',
|
|
9
|
-
path: ['path', 'to', 'token'],
|
|
10
|
-
}),
|
|
11
|
-
getMockToken({
|
|
12
|
-
name: 'tokenName',
|
|
13
|
-
path: ['PATH', 'tO', 'Token'],
|
|
14
|
-
}),
|
|
15
|
-
getMockToken({
|
|
16
|
-
name: 'tokenName',
|
|
17
|
-
path: ['path', 'toToken'],
|
|
18
|
-
}),
|
|
19
|
-
getMockToken({
|
|
20
|
-
name: 'tokenName',
|
|
21
|
-
path: ['pathtoToken'],
|
|
22
|
-
}),
|
|
23
|
-
]
|
|
24
|
-
const expectedOutput = ['pathToToken', 'PATHTOToken', 'pathToToken', 'pathtoToken']
|
|
25
|
-
|
|
26
|
-
expect(input.map(item => namePathToCamelCase.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it('replaces spaces, `-`, `_` and `+` within path elements and joins with camelCase, but does not change the rest of the word', () => {
|
|
30
|
-
const input = [
|
|
31
|
-
getMockToken({
|
|
32
|
-
name: 'tokenName',
|
|
33
|
-
path: ['start', 'path to token'],
|
|
34
|
-
}),
|
|
35
|
-
getMockToken({
|
|
36
|
-
name: 'tokenName',
|
|
37
|
-
path: ['start', 'PATH_tO-+Token'],
|
|
38
|
-
}),
|
|
39
|
-
getMockToken({
|
|
40
|
-
name: 'tokenName',
|
|
41
|
-
path: ['start', 'path+toToken'],
|
|
42
|
-
}),
|
|
43
|
-
]
|
|
44
|
-
const expectedOutput = ['startPathToToken', 'startPATHTOToken', 'startPathToToken']
|
|
45
|
-
expect(input.map(item => namePathToCamelCase.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
it('removes `@`, so we can use it for the default hack', () => {
|
|
49
|
-
const input = [
|
|
50
|
-
getMockToken({
|
|
51
|
-
name: 'tokenName',
|
|
52
|
-
path: ['fgColor', 'accent', '@'],
|
|
53
|
-
}),
|
|
54
|
-
getMockToken({
|
|
55
|
-
name: 'tokenName',
|
|
56
|
-
path: ['fgColor', '@', 'muted'],
|
|
57
|
-
}),
|
|
58
|
-
]
|
|
59
|
-
const expectedOutput = ['fgColorAccent', 'fgColorMuted']
|
|
60
|
-
expect(input.map(item => namePathToCamelCase.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
it('adds prefix to token name', () => {
|
|
64
|
-
const platform = {
|
|
65
|
-
prefix: 'PRIMER',
|
|
66
|
-
}
|
|
67
|
-
const input = getMockToken({
|
|
68
|
-
name: 'tokenName',
|
|
69
|
-
path: ['start', 'pathTo', 'token'],
|
|
70
|
-
})
|
|
71
|
-
const expectedOutput = 'PRIMERStartPathToToken'
|
|
72
|
-
expect(namePathToCamelCase.transformer(input, platform)).toStrictEqual(expectedOutput)
|
|
73
|
-
})
|
|
74
|
-
})
|