Skip to content

Commit

Permalink
feat(transform): code review, drop "px" check
Browse files Browse the repository at this point in the history
  • Loading branch information
jbarreiros committed Dec 5, 2020
1 parent 9f7efa0 commit ab1cbda
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
11 changes: 5 additions & 6 deletions __tests__/common/transforms.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,16 +547,15 @@ describe('common', () => {
describe('size/pxToRem', () => {
const pxToRemTransformer = transforms["size/pxToRem"].transformer;

it('converts pixel to rem', () => {
expect(pxToRemTransformer({value: '12px'})).toBe('0.75rem');
['12', '12px', '12rem'].forEach((value) => {
it(`ignoring unit, scales "${value}" to rem`, () => {
expect(pxToRemTransformer({value})).toBe('0.75rem');
});
});
it('converts pixel to rem using custom base font', () => {
expect(pxToRemTransformer({value: '14px'}, {basePxFontSize: 14})).toBe('1rem');
});
it('nonzero rem value not changed', () => {
expect(pxToRemTransformer({value: '2rem'})).toBe('2rem');
});
['0px', '0', '0rem'].forEach((value) => {
['0', '0px', '0rem'].forEach((value) => {
it(`zero value "${value}" is returned without a unit`, () => {
expect(pxToRemTransformer({value})).toBe('0');
});
Expand Down
5 changes: 0 additions & 5 deletions lib/common/transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -721,11 +721,6 @@ module.exports = {
return '0';
}

if (String(prop.value).indexOf('px') === -1) {
// ignore anything without a "px" unit
return prop.value;
}

return `${floatVal / baseFont}rem`;
}
},
Expand Down

0 comments on commit ab1cbda

Please sign in to comment.