diff --git a/test/spec/checkAndEvaluateMath.spec.ts b/test/spec/checkAndEvaluateMath.spec.ts index 2c47c0d..d0f2afc 100644 --- a/test/spec/checkAndEvaluateMath.spec.ts +++ b/test/spec/checkAndEvaluateMath.spec.ts @@ -33,10 +33,19 @@ describe('check and evaluate math', () => { // we can strip the unit, do the calculation, and add back the unit. // However, there's not really a good way to do calculations with mixed units, // e.g. 2em * 4rem is not possible - it.skip('can evaluate math expressions where more than one token has a unit, as long as for each piece of the expression the unit is the same', () => { - expect(checkAndEvaluateMath('4em * 7em')).to.equal('28em'); - expect(checkAndEvaluateMath('4pt * 7pt * 8pt')).to.equal('228pt'); - expect(checkAndEvaluateMath('4pt * 10vw * 8pt')).to.equal('4pt * 10vw * 8pt'); + it('can evaluate math expressions where more than one token has a unit, as long as for each piece of the expression the unit is the same', () => { + // can resolve them, because all values share the same unit + // TODO: implement tests below, failing atm + expect(checkAndEvaluateMath('5rem * 4rem / 2rem')).to.equal('10rem'); // current: '5rem * 4rem / 2rem' + expect(checkAndEvaluateMath('10vw + 20vw')).to.equal('10vw'); // current: '10vw + 20vw' + + // cannot resolve them, because em is dynamic and 20/20px is static value + expect(checkAndEvaluateMath('2em + 20')).to.equal('2em + 20'); + expect(checkAndEvaluateMath('2em + 20px')).to.equal('2em + 20px'); + + // can resolve them, because multiplying by pixels/unitless is possible, regardless of the other value's unit + expect(checkAndEvaluateMath('2pt * 4')).to.equal('8pt'); + expect(checkAndEvaluateMath('2em * 20px')).to.equal('40em'); }); it('supports multi-value expressions with math expressions', () => {