|
@ -37,6 +37,13 @@ describe('px-to-viewport', function() { |
|
|
|
|
|
|
|
|
expect(processed).toBe(expected); |
|
|
expect(processed).toBe(expected); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should remain unitless if 0', function () { |
|
|
|
|
|
var expected = '.rule { font-size: 0px; font-size: 0; }'; |
|
|
|
|
|
var processed = postcss(pxToViewport()).process(expected).css; |
|
|
|
|
|
|
|
|
|
|
|
expect(processed).toBe(expected); |
|
|
|
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
describe('value parsing', function() { |
|
|
describe('value parsing', function() { |
|
@ -58,6 +65,14 @@ describe('value parsing', function() { |
|
|
|
|
|
|
|
|
expect(processed).toBe(expected); |
|
|
expect(processed).toBe(expected); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should not replace values with an uppercase P or X', function () { |
|
|
|
|
|
var rules = '.rule { margin: 12px calc(100% - 14PX); height: calc(100% - 20px); font-size: 12Px; line-height: 16px; }'; |
|
|
|
|
|
var expected = '.rule { margin: 3.75vw calc(100% - 14PX); height: calc(100% - 6.25vw); font-size: 12Px; line-height: 5vw; }'; |
|
|
|
|
|
var processed = postcss(pxToViewport()).process(rules).css; |
|
|
|
|
|
|
|
|
|
|
|
expect(processed).toBe(expected); |
|
|
|
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
describe('unitToConvert', function() { |
|
|
describe('unitToConvert', function() { |
|
@ -230,52 +245,100 @@ describe('minPixelValue', function () { |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe('exclude', function () { |
|
|
|
|
|
var rules = '.rule { border: 1px solid #000; font-size: 16px; margin: 1px 10px; }'; |
|
|
|
|
|
var covered = '.rule { border: 1px solid #000; font-size: 5vw; margin: 1px 3.125vw; }' |
|
|
|
|
|
it('when using regex at the time, the style should not be overwritten.', function () { |
|
|
|
|
|
var options = { |
|
|
|
|
|
exclude: /node_modules/ |
|
|
|
|
|
} |
|
|
|
|
|
var processed = postcss(pxToViewport(options)).process(rules, { |
|
|
|
|
|
from: '/node_modules/main.css' |
|
|
|
|
|
}).css; |
|
|
|
|
|
|
|
|
|
|
|
expect(processed).toBe(rules); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('when using regex at the time, the style should be overwritten.', function () { |
|
|
|
|
|
var options = { |
|
|
|
|
|
exclude: /node_modules/ |
|
|
|
|
|
} |
|
|
|
|
|
var processed = postcss(pxToViewport(options)).process(rules, { |
|
|
|
|
|
from: '/example/main.css' |
|
|
|
|
|
}).css; |
|
|
|
|
|
|
|
|
|
|
|
expect(processed).toBe(covered); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('when using array at the time, the style should not be overwritten.', function () { |
|
|
|
|
|
var options = { |
|
|
|
|
|
exclude: [/node_modules/, /exclude/] |
|
|
|
|
|
} |
|
|
|
|
|
var processed = postcss(pxToViewport(options)).process(rules, { |
|
|
|
|
|
from: '/exclude/main.css' |
|
|
|
|
|
}).css; |
|
|
|
|
|
|
|
|
|
|
|
expect(processed).toBe(rules); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('when using array at the time, the style should be overwritten.', function () { |
|
|
|
|
|
var options = { |
|
|
|
|
|
exclude: [/node_modules/, /exclude/] |
|
|
|
|
|
} |
|
|
|
|
|
var processed = postcss(pxToViewport(options)).process(rules, { |
|
|
|
|
|
from: '/example/main.css' |
|
|
|
|
|
}).css; |
|
|
|
|
|
|
|
|
|
|
|
expect(processed).toBe(covered); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
describe('filter-prop-list', function () { |
|
|
describe('filter-prop-list', function () { |
|
|
it('should find "exact" matches from propList', function () { |
|
|
it('should find "exact" matches from propList', function () { |
|
|
var propList = ['font-size', 'margin', '!padding', '*border*', '*', '*y', '!*font*']; |
|
|
|
|
|
var expected = 'font-size,margin'; |
|
|
|
|
|
expect(filterPropList.exact(propList).join()).toBe(expected); |
|
|
|
|
|
|
|
|
var propList = ['font-size', 'margin', '!padding', '*border*', '*', '*y', '!*font*']; |
|
|
|
|
|
var expected = 'font-size,margin'; |
|
|
|
|
|
expect(filterPropList.exact(propList).join()).toBe(expected); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('should find "contain" matches from propList and reduce to string', function () { |
|
|
it('should find "contain" matches from propList and reduce to string', function () { |
|
|
var propList = ['font-size', '*margin*', '!padding', '*border*', '*', '*y', '!*font*']; |
|
|
|
|
|
var expected = 'margin,border'; |
|
|
|
|
|
expect(filterPropList.contain(propList).join()).toBe(expected); |
|
|
|
|
|
|
|
|
var propList = ['font-size', '*margin*', '!padding', '*border*', '*', '*y', '!*font*']; |
|
|
|
|
|
var expected = 'margin,border'; |
|
|
|
|
|
expect(filterPropList.contain(propList).join()).toBe(expected); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('should find "start" matches from propList and reduce to string', function () { |
|
|
it('should find "start" matches from propList and reduce to string', function () { |
|
|
var propList = ['font-size', '*margin*', '!padding', 'border*', '*', '*y', '!*font*']; |
|
|
|
|
|
var expected = 'border'; |
|
|
|
|
|
expect(filterPropList.startWith(propList).join()).toBe(expected); |
|
|
|
|
|
|
|
|
var propList = ['font-size', '*margin*', '!padding', 'border*', '*', '*y', '!*font*']; |
|
|
|
|
|
var expected = 'border'; |
|
|
|
|
|
expect(filterPropList.startWith(propList).join()).toBe(expected); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('should find "end" matches from propList and reduce to string', function () { |
|
|
it('should find "end" matches from propList and reduce to string', function () { |
|
|
var propList = ['font-size', '*margin*', '!padding', 'border*', '*', '*y', '!*font*']; |
|
|
|
|
|
var expected = 'y'; |
|
|
|
|
|
expect(filterPropList.endWith(propList).join()).toBe(expected); |
|
|
|
|
|
|
|
|
var propList = ['font-size', '*margin*', '!padding', 'border*', '*', '*y', '!*font*']; |
|
|
|
|
|
var expected = 'y'; |
|
|
|
|
|
expect(filterPropList.endWith(propList).join()).toBe(expected); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('should find "not" matches from propList and reduce to string', function () { |
|
|
it('should find "not" matches from propList and reduce to string', function () { |
|
|
var propList = ['font-size', '*margin*', '!padding', 'border*', '*', '*y', '!*font*']; |
|
|
|
|
|
var expected = 'padding'; |
|
|
|
|
|
expect(filterPropList.notExact(propList).join()).toBe(expected); |
|
|
|
|
|
|
|
|
var propList = ['font-size', '*margin*', '!padding', 'border*', '*', '*y', '!*font*']; |
|
|
|
|
|
var expected = 'padding'; |
|
|
|
|
|
expect(filterPropList.notExact(propList).join()).toBe(expected); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('should find "not contain" matches from propList and reduce to string', function () { |
|
|
it('should find "not contain" matches from propList and reduce to string', function () { |
|
|
var propList = ['font-size', '*margin*', '!padding', '!border*', '*', '*y', '!*font*']; |
|
|
|
|
|
var expected = 'font'; |
|
|
|
|
|
expect(filterPropList.notContain(propList).join()).toBe(expected); |
|
|
|
|
|
|
|
|
var propList = ['font-size', '*margin*', '!padding', '!border*', '*', '*y', '!*font*']; |
|
|
|
|
|
var expected = 'font'; |
|
|
|
|
|
expect(filterPropList.notContain(propList).join()).toBe(expected); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('should find "not start" matches from propList and reduce to string', function () { |
|
|
it('should find "not start" matches from propList and reduce to string', function () { |
|
|
var propList = ['font-size', '*margin*', '!padding', '!border*', '*', '*y', '!*font*']; |
|
|
|
|
|
var expected = 'border'; |
|
|
|
|
|
expect(filterPropList.notStartWith(propList).join()).toBe(expected); |
|
|
|
|
|
|
|
|
var propList = ['font-size', '*margin*', '!padding', '!border*', '*', '*y', '!*font*']; |
|
|
|
|
|
var expected = 'border'; |
|
|
|
|
|
expect(filterPropList.notStartWith(propList).join()).toBe(expected); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('should find "not end" matches from propList and reduce to string', function () { |
|
|
it('should find "not end" matches from propList and reduce to string', function () { |
|
|
var propList = ['font-size', '*margin*', '!padding', '!border*', '*', '!*y', '!*font*']; |
|
|
|
|
|
var expected = 'y'; |
|
|
|
|
|
expect(filterPropList.notEndWith(propList).join()).toBe(expected); |
|
|
|
|
|
|
|
|
var propList = ['font-size', '*margin*', '!padding', '!border*', '*', '!*y', '!*font*']; |
|
|
|
|
|
var expected = 'y'; |
|
|
|
|
|
expect(filterPropList.notEndWith(propList).join()).toBe(expected); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |