Skip to content

Commit 0e7ce70

Browse files
author
Dario Soller
committed
tests(unit): add mix modifier value calculation unit test
1 parent 72bca07 commit 0e7ce70

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/spec/color-modifiers/transformColorModifiers.spec.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,35 @@ describe('transform color modifiers', () => {
105105
// without space, return original
106106
expect(transformColorModifiers(token(''))).to.equal('#000000');
107107
});
108+
109+
it('supports mix modifier value calculations', () => {
110+
const token = (space: ColorSpaceTypes | '', format?) => ({
111+
value: '#FFFFFF',
112+
type: 'color',
113+
$extensions: {
114+
'studio.tokens': {
115+
modify: {
116+
type: 'mix',
117+
value: '0.5 + 6 * 0.04',
118+
color: '#4477DD',
119+
space,
120+
format,
121+
},
122+
},
123+
},
124+
});
125+
126+
expect(transformColorModifiers(token(ColorSpaceTypes.HSL))).to.equal('hsl(220 51.2% 67.9%)');
127+
expect(transformColorModifiers(token(ColorSpaceTypes.LCH))).to.equal('lch(63.4 43.7 279)');
128+
expect(transformColorModifiers(token(ColorSpaceTypes.P3))).to.equal(
129+
'color(display-p3 0.49 0.6 0.88)',
130+
);
131+
expect(transformColorModifiers(token(ColorSpaceTypes.SRGB))).to.equal(
132+
'rgb(45.7% 60.5% 90.1%)',
133+
);
134+
expect(transformColorModifiers(token(''))).to.equal('#FFFFFF');
135+
expect(transformColorModifiers(token(ColorSpaceTypes.SRGB, 'hex'))).to.equal('#759ae6');
136+
});
108137
});
109138

110139
describe('transparentize', () => {

0 commit comments

Comments
 (0)