Skip to content

Commit

Permalink
chore: update integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Razinsky committed Jul 3, 2024
1 parent 0686e9d commit fbcd169
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/integration/sd-transforms.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type StyleDictionary from 'style-dictionary';
import * as SD from 'style-dictionary';
import { expect } from 'chai';
import { promises } from 'node:fs';
import path from 'node:path';
Expand Down Expand Up @@ -74,6 +75,7 @@ describe('sd-transforms smoke tests', () => {
--sdShadowBlur: 10px;
--sdShadow: inset 0 4px 10px 0 rgba(0,0,0,0.4);
--sdBorderWidth: 5px;
--sdBorderWidthRem: 0.3125rem;
--sdBorder: 5px solid #000000;
--sdColor: #ff00ff;
--sdUsesColor: rgba(255, 0, 255, 1);
Expand Down Expand Up @@ -129,6 +131,7 @@ describe('sd-transforms smoke tests', () => {
--sd-shadow-blur: 10px;
--sd-shadow: inset 0 4px 10px 0 rgba(0,0,0,0.4);
--sd-border-width: 5px;
--sd-border-width-rem: 0.3125rem;
--sd-border: 5px solid #000000;
--sd-color: #ff00ff;
--sd-uses-color: rgba(255, 0, 255, 1);
Expand All @@ -155,4 +158,24 @@ describe('sd-transforms smoke tests', () => {
type: 'scale',
});
});

it('allows a `mathFractionDigits` option to control the rounding of values in math', async () => {
await cleanup(dict);
dict = await init(
{
...cfg,
platforms: {
css: {
...cfg.platforms.css,
options: {
mathFractionDigits: 3,
},
},
},
},
{ 'ts/color/modifiers': { format: 'hex' } },
);
const enrichedTokens = await dict?.exportPlatform('css'); // platform to parse for is 'css' in this case
expect((enrichedTokens?.['border-width-rem'] as SD.TransformedToken).value).to.eql('0.313rem');
});
});
4 changes: 4 additions & 0 deletions test/integration/tokens/sd-transforms.tokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@
"value": "5",
"type": "sizing"
},
"border-width-rem": {
"value": "{border-width} / 16 * 1rem",
"type": "borderWidths"
},
"border": {
"value": {
"style": "solid",
Expand Down

0 comments on commit fbcd169

Please sign in to comment.