-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Explose the entire token set internally (#76)
- Loading branch information
1 parent
5a001b7
commit 6229f0e
Showing
4 changed files
with
40 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 26 additions & 4 deletions
30
src/build/tasks/__tests__/__snapshots__/internal-tokens.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,37 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`generateTokensDeclarationFile matches previous snapshot 1`] = ` | ||
"export const shadow: string; | ||
"export const fontFamilyBase: string; | ||
export const fontFamilyBody: string; | ||
export const black: string; | ||
export const grey: string; | ||
export const brown: string; | ||
export const shadow: string; | ||
export const buttonShadow: string; | ||
export const boxShadow: string; | ||
export const lineShadow: string;" | ||
export const lineShadow: string; | ||
export const small: string; | ||
export const medium: string; | ||
export const scaledSize: string; | ||
export const appear: string; | ||
export const containerShadowBase: string; | ||
export const modalShadowContainer: string;" | ||
`; | ||
|
||
exports[`generateTokensFile matches previous snapshot 1`] = ` | ||
"export var shadow = "var(--shadow-css, grey)"; | ||
"export var black = "var(--black-css, black)"; | ||
export var grey = "var(--grey-css, grey)"; | ||
export var brown = "var(--brown-css, brown)"; | ||
export var shadow = "var(--shadow-css, grey)"; | ||
export var buttonShadow = "var(--buttonShadow-css, grey)"; | ||
export var boxShadow = "var(--boxShadow-css, grey)"; | ||
export var lineShadow = "var(--lineShadow-css, grey)";" | ||
export var lineShadow = "var(--lineShadow-css, grey)"; | ||
export var small = "var(--small-css, 1px)"; | ||
export var medium = "var(--medium-css, 3px)"; | ||
export var scaledSize = "var(--scaledSize-css, 3px)"; | ||
export var appear = "var(--appear-css, 20ms)"; | ||
export var fontFamilyBase = "var(--fontFamilyBase-css, "Helvetica Neue", Arial, sans-serif)"; | ||
export var fontFamilyBody = "var(--fontFamilyBody-css, "Helvetica Neue", Arial, sans-serif)"; | ||
export var containerShadowBase = "var(--containerShadowBase-css, 2px 3px orange, -1px 0 8px olive)"; | ||
export var modalShadowContainer = "var(--modalShadowContainer-css, 2px 3px orange, -1px 0 8px olive)";" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,16 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import { test, expect } from 'vitest'; | ||
import { rootTheme, defaultsResolution, preset } from '../../../__fixtures__/common'; | ||
import { defaultsResolution, preset } from '../../../__fixtures__/common'; | ||
|
||
import { generateTokensDeclarationFile, generateTokensFile } from '../internal-tokens'; | ||
|
||
const propertiesMap = preset.propertiesMap; | ||
const publicTokens = preset.exposed; | ||
|
||
test('generateTokensFile matches previous snapshot', () => { | ||
expect(generateTokensFile(rootTheme, defaultsResolution, propertiesMap, publicTokens)).toMatchSnapshot(); | ||
expect(generateTokensFile(defaultsResolution, propertiesMap)).toMatchSnapshot(); | ||
}); | ||
|
||
test('generateTokensDeclarationFile matches previous snapshot', () => { | ||
expect(generateTokensDeclarationFile(publicTokens)).toMatchSnapshot(); | ||
}); | ||
|
||
test('throws error for missing custom properties', () => { | ||
const func = () => { | ||
generateTokensFile(rootTheme, defaultsResolution, {}, publicTokens); | ||
}; | ||
expect(func).toThrowError(new Error('Token shadow is not mapped to a CSS Custom Property')); | ||
expect(generateTokensDeclarationFile(propertiesMap)).toMatchSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters