@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,74 +0,0 @@
|
|
|
1
|
-
import {getMockToken} from '../test-utilities'
|
|
2
|
-
import {namePathToDotNotation} from './namePathToDotNotation'
|
|
3
|
-
|
|
4
|
-
describe('Transformer: namePathToDotNotation', () => {
|
|
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 = ['path.to.token', 'PATH.tO.Token', 'path.toToken', 'pathtoToken']
|
|
25
|
-
|
|
26
|
-
expect(input.map(item => namePathToDotNotation.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 = ['start.pathToToken', 'start.PATHTOToken', 'start.pathToToken']
|
|
45
|
-
expect(input.map(item => namePathToDotNotation.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 = ['fgColor.accent', 'fgColor.muted']
|
|
60
|
-
expect(input.map(item => namePathToDotNotation.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 = 'PRIMER.start.pathTo.token'
|
|
72
|
-
expect(namePathToDotNotation.transformer(input, platform)).toStrictEqual(expectedOutput)
|
|
73
|
-
})
|
|
74
|
-
})
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import {getMockToken} from '../test-utilities'
|
|
2
|
-
import {namePathToFigma} from './namePathToFigma'
|
|
3
|
-
|
|
4
|
-
describe('Transformer: namePathToFigma', () => {
|
|
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 = ['path/to/token', 'PATH/tO/Token', 'path/toToken', 'pathtoToken']
|
|
25
|
-
|
|
26
|
-
expect(input.map(item => namePathToFigma.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 = ['start/path to token', 'start/PATH_tO-Token', 'start/path+toToken']
|
|
45
|
-
expect(input.map(item => namePathToFigma.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 = ['fgColor/accent', 'fgColor/muted']
|
|
60
|
-
expect(input.map(item => namePathToFigma.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 = 'PRIMER/start/pathTo/token'
|
|
72
|
-
expect(namePathToFigma.transformer(input, platform)).toStrictEqual(expectedOutput)
|
|
73
|
-
})
|
|
74
|
-
})
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import {getMockToken} from '../test-utilities'
|
|
2
|
-
import {namePathToKebabCase} from './namePathToKebabCase'
|
|
3
|
-
|
|
4
|
-
describe('Transformer: namePathToKebabCase', () => {
|
|
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 = ['path-to-token', 'PATH-tO-Token', 'path-toToken', 'pathtoToken']
|
|
25
|
-
|
|
26
|
-
expect(input.map(item => namePathToKebabCase.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 = ['start-path to token', 'start-PATH_tO-Token', 'start-path+toToken']
|
|
45
|
-
expect(input.map(item => namePathToKebabCase.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 = ['fgColor-accent', 'fgColor-muted']
|
|
60
|
-
expect(input.map(item => namePathToKebabCase.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 = 'PRIMER-start-pathTo-token'
|
|
72
|
-
expect(namePathToKebabCase.transformer(input, platform)).toStrictEqual(expectedOutput)
|
|
73
|
-
})
|
|
74
|
-
})
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import {getMockToken} from '../test-utilities'
|
|
2
|
-
import {namePathToSlashNotation} from './namePathToSlashNotation'
|
|
3
|
-
|
|
4
|
-
describe('Transformer: namePathToSlashNotation', () => {
|
|
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 = ['path/to/token', 'PATH/tO/Token', 'path/toToken', 'pathtoToken']
|
|
25
|
-
|
|
26
|
-
expect(input.map(item => namePathToSlashNotation.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 = ['start/path to token', 'start/PATH_tO-Token', 'start/path+toToken']
|
|
45
|
-
expect(input.map(item => namePathToSlashNotation.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 = ['fgColor/accent', 'fgColor/muted']
|
|
60
|
-
expect(input.map(item => namePathToSlashNotation.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 = 'PRIMER/start/pathTo/token'
|
|
72
|
-
expect(namePathToSlashNotation.transformer(input, platform)).toStrictEqual(expectedOutput)
|
|
73
|
-
})
|
|
74
|
-
})
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import {getMockToken} from '../test-utilities'
|
|
2
|
-
import {shadowToCss} from './shadowToCss'
|
|
3
|
-
|
|
4
|
-
describe('Transformer: shadowToCss', () => {
|
|
5
|
-
it('transforms `shadow` token to css shadow string', () => {
|
|
6
|
-
const input = [
|
|
7
|
-
getMockToken({
|
|
8
|
-
value: {
|
|
9
|
-
color: '#000000',
|
|
10
|
-
offsetX: '0px',
|
|
11
|
-
offsetY: '2px',
|
|
12
|
-
blur: '1px',
|
|
13
|
-
spread: '0',
|
|
14
|
-
},
|
|
15
|
-
}),
|
|
16
|
-
]
|
|
17
|
-
const expectedOutput = ['0px 2px 1px 0 #000000']
|
|
18
|
-
expect(input.map(item => shadowToCss.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
it('transforms inset `shadow` token to css shadow string', () => {
|
|
22
|
-
const input = [
|
|
23
|
-
getMockToken({
|
|
24
|
-
value: {
|
|
25
|
-
color: '#000000',
|
|
26
|
-
offsetX: '0px',
|
|
27
|
-
offsetY: '2px',
|
|
28
|
-
blur: '1px',
|
|
29
|
-
spread: '0px',
|
|
30
|
-
inset: true,
|
|
31
|
-
},
|
|
32
|
-
}),
|
|
33
|
-
getMockToken({
|
|
34
|
-
value: {
|
|
35
|
-
color: '#000000',
|
|
36
|
-
offsetX: '0px',
|
|
37
|
-
offsetY: '2px',
|
|
38
|
-
blur: '1px',
|
|
39
|
-
spread: '0px',
|
|
40
|
-
inset: false,
|
|
41
|
-
},
|
|
42
|
-
}),
|
|
43
|
-
]
|
|
44
|
-
const expectedOutput = ['inset 0px 2px 1px 0px #000000', '0px 2px 1px 0px #000000']
|
|
45
|
-
expect(input.map(item => shadowToCss.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
it('throws an error when required values are missing', () => {
|
|
49
|
-
// missing blur
|
|
50
|
-
expect(() =>
|
|
51
|
-
shadowToCss.transformer(
|
|
52
|
-
getMockToken({
|
|
53
|
-
value: {
|
|
54
|
-
color: '#000000',
|
|
55
|
-
offsetX: '2px',
|
|
56
|
-
offsetY: '2px',
|
|
57
|
-
blur: '1px',
|
|
58
|
-
},
|
|
59
|
-
}),
|
|
60
|
-
{},
|
|
61
|
-
),
|
|
62
|
-
).toThrowError()
|
|
63
|
-
|
|
64
|
-
// missing spread
|
|
65
|
-
expect(() =>
|
|
66
|
-
shadowToCss.transformer(
|
|
67
|
-
getMockToken({
|
|
68
|
-
value: {
|
|
69
|
-
color: '#000000',
|
|
70
|
-
offsetX: '2px',
|
|
71
|
-
offsetY: '2px',
|
|
72
|
-
blur: '1px',
|
|
73
|
-
},
|
|
74
|
-
}),
|
|
75
|
-
{},
|
|
76
|
-
),
|
|
77
|
-
).toThrowError()
|
|
78
|
-
|
|
79
|
-
// missing offsets
|
|
80
|
-
expect(() =>
|
|
81
|
-
shadowToCss.transformer(
|
|
82
|
-
getMockToken({
|
|
83
|
-
value: {
|
|
84
|
-
color: '#000000',
|
|
85
|
-
offsetX: '2px',
|
|
86
|
-
spread: '0px',
|
|
87
|
-
blur: '1px',
|
|
88
|
-
},
|
|
89
|
-
}),
|
|
90
|
-
{},
|
|
91
|
-
),
|
|
92
|
-
).toThrowError()
|
|
93
|
-
|
|
94
|
-
expect(() =>
|
|
95
|
-
shadowToCss.transformer(
|
|
96
|
-
getMockToken({
|
|
97
|
-
value: {
|
|
98
|
-
color: '#000000',
|
|
99
|
-
offsetY: '2px',
|
|
100
|
-
spread: '0px',
|
|
101
|
-
blur: '1px',
|
|
102
|
-
},
|
|
103
|
-
}),
|
|
104
|
-
{},
|
|
105
|
-
),
|
|
106
|
-
).toThrowError()
|
|
107
|
-
// missing color
|
|
108
|
-
expect(() =>
|
|
109
|
-
shadowToCss.transformer(
|
|
110
|
-
getMockToken({
|
|
111
|
-
value: {
|
|
112
|
-
offsetX: '0px',
|
|
113
|
-
offsetY: '2px',
|
|
114
|
-
spread: '0px',
|
|
115
|
-
blur: '1px',
|
|
116
|
-
},
|
|
117
|
-
}),
|
|
118
|
-
{},
|
|
119
|
-
),
|
|
120
|
-
).toThrowError()
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
it('transforms `shadow` token alpha value to css shadow string', () => {
|
|
124
|
-
const input = [
|
|
125
|
-
getMockToken({
|
|
126
|
-
value: {
|
|
127
|
-
color: '#000000',
|
|
128
|
-
offsetX: '0px',
|
|
129
|
-
offsetY: '2px',
|
|
130
|
-
blur: '1px',
|
|
131
|
-
spread: '0',
|
|
132
|
-
alpha: 0.5,
|
|
133
|
-
},
|
|
134
|
-
}),
|
|
135
|
-
getMockToken({
|
|
136
|
-
value: {
|
|
137
|
-
color: '#22222266',
|
|
138
|
-
offsetX: '0px',
|
|
139
|
-
offsetY: '2px',
|
|
140
|
-
blur: '1px',
|
|
141
|
-
spread: '0',
|
|
142
|
-
alpha: 0.5,
|
|
143
|
-
},
|
|
144
|
-
}),
|
|
145
|
-
]
|
|
146
|
-
const expectedOutput = ['0px 2px 1px 0 #00000080', '0px 2px 1px 0 #22222280']
|
|
147
|
-
expect(input.map(item => shadowToCss.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
148
|
-
})
|
|
149
|
-
|
|
150
|
-
it('transforms multi-layer `shadow` token to css shadow string', () => {
|
|
151
|
-
const item = getMockToken({
|
|
152
|
-
value: [
|
|
153
|
-
{
|
|
154
|
-
color: '#000000',
|
|
155
|
-
offsetX: '0px',
|
|
156
|
-
offsetY: '2px',
|
|
157
|
-
blur: '1px',
|
|
158
|
-
spread: '0',
|
|
159
|
-
alpha: 0.5,
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
color: '#22222266',
|
|
163
|
-
offsetX: '0px',
|
|
164
|
-
offsetY: '8px',
|
|
165
|
-
blur: '16px',
|
|
166
|
-
spread: '0',
|
|
167
|
-
alpha: 0.2,
|
|
168
|
-
},
|
|
169
|
-
],
|
|
170
|
-
})
|
|
171
|
-
|
|
172
|
-
const expectedOutput = '0px 2px 1px 0 #00000080, 0px 8px 16px 0 #22222233'
|
|
173
|
-
expect(shadowToCss.transformer(item, {})).toStrictEqual(expectedOutput)
|
|
174
|
-
})
|
|
175
|
-
})
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import {getMockToken} from '../test-utilities'
|
|
2
|
-
import {typographyToCss} from './typographyToCss'
|
|
3
|
-
|
|
4
|
-
describe('Transformer: typographyToCss', () => {
|
|
5
|
-
it('transforms `typography` token to css typography string', () => {
|
|
6
|
-
const input = getMockToken({
|
|
7
|
-
value: {
|
|
8
|
-
fontFamily: 'Roboto',
|
|
9
|
-
fontSize: '42px',
|
|
10
|
-
fontWeight: 700,
|
|
11
|
-
letterSpacing: '0.1px',
|
|
12
|
-
lineHeight: '1.2',
|
|
13
|
-
},
|
|
14
|
-
})
|
|
15
|
-
const expectedOutput = '700 42px/1.2 Roboto'
|
|
16
|
-
expect(typographyToCss.transformer(input, {})).toStrictEqual(expectedOutput)
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
it('transforms `typography` with custom `fontStyle` prop token to css typography string', () => {
|
|
20
|
-
const input = getMockToken({
|
|
21
|
-
value: {
|
|
22
|
-
fontFamily: 'Roboto',
|
|
23
|
-
fontSize: '2rem',
|
|
24
|
-
fontWeight: 700,
|
|
25
|
-
fontStyle: 'italic',
|
|
26
|
-
lineHeight: '1.2',
|
|
27
|
-
},
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
const expectedOutput = 'italic 700 2rem/1.2 Roboto'
|
|
31
|
-
expect(typographyToCss.transformer(input, {})).toStrictEqual(expectedOutput)
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
it('transforms fontWeight string to number', () => {
|
|
35
|
-
const input = [
|
|
36
|
-
getMockToken({
|
|
37
|
-
value: {
|
|
38
|
-
fontFamily: 'Roboto',
|
|
39
|
-
fontSize: '42px',
|
|
40
|
-
fontWeight: '500',
|
|
41
|
-
letterSpacing: '0.1px',
|
|
42
|
-
lineHeight: '1.2',
|
|
43
|
-
},
|
|
44
|
-
}),
|
|
45
|
-
getMockToken({
|
|
46
|
-
value: {
|
|
47
|
-
fontFamily: 'Roboto',
|
|
48
|
-
fontSize: '42px',
|
|
49
|
-
fontWeight: 'black',
|
|
50
|
-
letterSpacing: '0.1px',
|
|
51
|
-
lineHeight: '1.2',
|
|
52
|
-
},
|
|
53
|
-
}),
|
|
54
|
-
]
|
|
55
|
-
const expectedOutput = ['500 42px/1.2 Roboto', '900 42px/1.2 Roboto']
|
|
56
|
-
expect(input.map(item => typographyToCss.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
it('transforms fontFamily string and array', () => {
|
|
60
|
-
const input = [
|
|
61
|
-
getMockToken({
|
|
62
|
-
value: {
|
|
63
|
-
fontFamily: 'Roboto, Noto Sans',
|
|
64
|
-
fontSize: '42px',
|
|
65
|
-
fontWeight: '700',
|
|
66
|
-
letterSpacing: '0.1px',
|
|
67
|
-
lineHeight: '1.2',
|
|
68
|
-
},
|
|
69
|
-
}),
|
|
70
|
-
getMockToken({
|
|
71
|
-
value: {
|
|
72
|
-
fontFamily: ['Roboto', 'Noto Sans'],
|
|
73
|
-
fontSize: '42px',
|
|
74
|
-
fontWeight: '700',
|
|
75
|
-
letterSpacing: '0.1px',
|
|
76
|
-
lineHeight: '1.2',
|
|
77
|
-
},
|
|
78
|
-
}),
|
|
79
|
-
]
|
|
80
|
-
const expectedOutput = ['700 42px/1.2 Roboto, Noto Sans', "700 42px/1.2 Roboto, 'Noto Sans'"]
|
|
81
|
-
expect(input.map(item => typographyToCss.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
it('transforms lineHeight string to number', () => {
|
|
85
|
-
const input = [
|
|
86
|
-
getMockToken({
|
|
87
|
-
value: {
|
|
88
|
-
fontFamily: 'Roboto',
|
|
89
|
-
fontSize: '42px',
|
|
90
|
-
fontWeight: '700',
|
|
91
|
-
letterSpacing: '0.1px',
|
|
92
|
-
lineHeight: '1.2',
|
|
93
|
-
},
|
|
94
|
-
}),
|
|
95
|
-
getMockToken({
|
|
96
|
-
value: {
|
|
97
|
-
fontFamily: 'Roboto',
|
|
98
|
-
fontSize: '42px',
|
|
99
|
-
fontWeight: '700',
|
|
100
|
-
letterSpacing: '0.1px',
|
|
101
|
-
lineHeight: '1rem',
|
|
102
|
-
},
|
|
103
|
-
}),
|
|
104
|
-
getMockToken({
|
|
105
|
-
value: {
|
|
106
|
-
fontFamily: 'Roboto',
|
|
107
|
-
fontSize: '42px',
|
|
108
|
-
fontWeight: '700',
|
|
109
|
-
letterSpacing: '0.1px',
|
|
110
|
-
lineHeight: '20px',
|
|
111
|
-
},
|
|
112
|
-
}),
|
|
113
|
-
]
|
|
114
|
-
const expectedOutput = ['700 42px/1.2 Roboto', '700 42px/1rem Roboto', '700 42px/20px Roboto']
|
|
115
|
-
expect(input.map(item => typographyToCss.transformer(item, {}))).toStrictEqual(expectedOutput)
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
it('throws an error when required values are missing', () => {
|
|
119
|
-
// missing fontFamily
|
|
120
|
-
expect(() =>
|
|
121
|
-
typographyToCss.transformer(
|
|
122
|
-
getMockToken({
|
|
123
|
-
value: {
|
|
124
|
-
fontSize: '42px',
|
|
125
|
-
fontWeight: '700',
|
|
126
|
-
letterSpacing: '0.1px',
|
|
127
|
-
lineHeight: '1.2',
|
|
128
|
-
},
|
|
129
|
-
}),
|
|
130
|
-
{},
|
|
131
|
-
),
|
|
132
|
-
).toThrowError()
|
|
133
|
-
|
|
134
|
-
// missing fontSize
|
|
135
|
-
expect(() =>
|
|
136
|
-
typographyToCss.transformer(
|
|
137
|
-
getMockToken({
|
|
138
|
-
value: {
|
|
139
|
-
fontFamily: 'Roboto',
|
|
140
|
-
fontWeight: '700',
|
|
141
|
-
letterSpacing: '0.1px',
|
|
142
|
-
lineHeight: '1.2',
|
|
143
|
-
},
|
|
144
|
-
}),
|
|
145
|
-
{},
|
|
146
|
-
),
|
|
147
|
-
).toThrowError()
|
|
148
|
-
|
|
149
|
-
// missing fontWeight
|
|
150
|
-
expect(() =>
|
|
151
|
-
typographyToCss.transformer(
|
|
152
|
-
getMockToken({
|
|
153
|
-
value: {
|
|
154
|
-
fontFamily: 'Roboto',
|
|
155
|
-
fontSize: '42px',
|
|
156
|
-
letterSpacing: '0.1px',
|
|
157
|
-
lineHeight: '1.2',
|
|
158
|
-
},
|
|
159
|
-
}),
|
|
160
|
-
{},
|
|
161
|
-
),
|
|
162
|
-
).toThrowError()
|
|
163
|
-
})
|
|
164
|
-
})
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import {alpha} from './alpha'
|
|
2
|
-
|
|
3
|
-
describe('Utilities: alpha', () => {
|
|
4
|
-
it('it transforms `hex3`', () => {
|
|
5
|
-
expect(alpha('#345', 0)).toStrictEqual('rgba(51, 68, 85, 0)')
|
|
6
|
-
expect(alpha('#345', 0.4)).toStrictEqual('rgba(51, 68, 85, 0.4)')
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
it('it transforms `hex6`', () => {
|
|
10
|
-
expect(alpha('#334455', 0)).toStrictEqual('rgba(51, 68, 85, 0)')
|
|
11
|
-
expect(alpha('#334455', 0.4)).toStrictEqual('rgba(51, 68, 85, 0.4)')
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
it('it transforms `hex8` by ignoring opacity in the color', () => {
|
|
15
|
-
expect(alpha('#33445566', 0)).toStrictEqual('rgba(51, 68, 85, 0)')
|
|
16
|
-
expect(alpha('#33445566', 0.4)).toStrictEqual('rgba(51, 68, 85, 0.4)')
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
it('it transforms `rgb`', () => {
|
|
20
|
-
expect(alpha('rgba(51, 68, 85)', 0)).toStrictEqual('rgba(51, 68, 85, 0)')
|
|
21
|
-
expect(alpha('rgba(51, 68, 85)', 0.4)).toStrictEqual('rgba(51, 68, 85, 0.4)')
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
it('it transforms `rgba` by ignoring opacity in the color', () => {
|
|
25
|
-
expect(alpha('rgba(51, 68, 85, 0.4)', 0)).toStrictEqual('rgba(51, 68, 85, 0)')
|
|
26
|
-
expect(alpha('rgba(51, 68, 85, 0.6)', 0.4)).toStrictEqual('rgba(51, 68, 85, 0.4)')
|
|
27
|
-
})
|
|
28
|
-
})
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import {checkRequiredTokenProperties} from './checkRequiredTokenProperties'
|
|
2
|
-
|
|
3
|
-
describe('Utilities: checkRequiredTokenProperties', () => {
|
|
4
|
-
it('it throws if property is missing', () => {
|
|
5
|
-
const requiredProps = ['propA', 'propB']
|
|
6
|
-
expect(() =>
|
|
7
|
-
checkRequiredTokenProperties(
|
|
8
|
-
{
|
|
9
|
-
propA: '42px',
|
|
10
|
-
},
|
|
11
|
-
requiredProps,
|
|
12
|
-
),
|
|
13
|
-
).toThrowError()
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
it('it does NOT throws if properties are present', () => {
|
|
17
|
-
const requiredProps = ['propA', 'propB']
|
|
18
|
-
expect(() =>
|
|
19
|
-
checkRequiredTokenProperties(
|
|
20
|
-
{
|
|
21
|
-
propA: '42px',
|
|
22
|
-
propB: '700',
|
|
23
|
-
},
|
|
24
|
-
requiredProps,
|
|
25
|
-
),
|
|
26
|
-
).not.toThrowError()
|
|
27
|
-
})
|
|
28
|
-
})
|