Skip to content

Commit

Permalink
chore: failing test for color modifier references
Browse files Browse the repository at this point in the history
  • Loading branch information
jorenbroekema committed Nov 3, 2023
1 parent 3c9a53e commit ccf01c3
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
51 changes: 51 additions & 0 deletions test/integration/color-modifier-references.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { expect } from '@esm-bundle/chai';
import StyleDictionary from 'style-dictionary';
import { promises } from 'fs';
import path from 'path';
import { cleanup, init } from './utils.js';

const outputDir = 'test/integration/tokens/';
const outputFileName = 'vars.css';
const outputFilePath = path.resolve(outputDir, outputFileName);

const cfg = {
source: ['test/integration/tokens/color-modifier-references.tokens.json'],
platforms: {
css: {
transformGroup: 'tokens-studio',
prefix: 'sd',
buildPath: outputDir,
files: [
{
destination: outputFileName,
format: 'css/variables',
},
],
},
},
};

let dict: StyleDictionary.Core | undefined;

describe('typography references', () => {
beforeEach(() => {
if (dict) {
cleanup(dict);
}
dict = init(cfg);
});

afterEach(() => {
if (dict) {
cleanup(dict);
}
});

it('supports references inside color modifiers', async () => {
const file = await promises.readFile(outputFilePath, 'utf-8');
expect(file).to.include(
`--sdAlpha: 0.3;
--sdColor: #FFFFFF4d;`,
);
});
});
20 changes: 20 additions & 0 deletions test/integration/tokens/color-modifier-references.tokens.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"alpha": {
"value": 0.3,
"type": "other"
},
"color": {
"value": "#FFFFFF",
"type": "color",
"$extensions": {
"studio.tokens": {
"modify": {
"type": "alpha",
"value": "{alpha}",
"space": "srgb",
"format": "hex"
}
}
}
}
}

0 comments on commit ccf01c3

Please sign in to comment.