Browse Source

add tests on propList

pull/20/head
Ivan Bunin 7 years ago
parent
commit
5f3c1b2a0f
  1. 2
      index.js
  2. 32
      spec/px-to-viewport.spec.js

2
index.js

@ -18,7 +18,7 @@ var defaults = {
};
module.exports = postcss.plugin('postcss-px-to-viewport', function (options) {
var opts = objectAssign({}, defaults, options);
var pxReplace = createPxReplace(opts.viewportWidth, opts.minPixelValue, opts.unitPrecision, opts.viewportUnit);

32
spec/px-to-viewport.spec.js

@ -184,6 +184,38 @@ describe('mediaQuery', function () {
});
});
describe('propList', function () {
it('should only replace properties in the prop list', function () {
var css = '.rule { font-size: 16px; margin: 16px; margin-left: 5px; padding: 5px; padding-right: 16px }';
var expected = '.rule { font-size: 5vw; margin: 5vw; margin-left: 5px; padding: 5px; padding-right: 5vw }';
var options = {
propList: ['*font*', 'margin*', '!margin-left', '*-right', 'pad']
};
var processed = postcss(pxToViewport(options)).process(css).css;
expect(processed).toBe(expected);
});
it('should only replace properties in the prop list with wildcard', function () {
var css = '.rule { font-size: 16px; margin: 16px; margin-left: 5px; padding: 5px; padding-right: 16px }';
var expected = '.rule { font-size: 16px; margin: 5vw; margin-left: 5px; padding: 5px; padding-right: 16px }';
var options = {
propList: ['*', '!margin-left', '!*padding*', '!font*']
};
var processed = postcss(pxToViewport(options)).process(css).css;
expect(processed).toBe(expected);
});
it('should replace all properties when prop list is not given', function () {
var rules = '.rule { margin: 16px; font-size: 15px }';
var expected = '.rule { margin: 5vw; font-size: 4.6875vw }';
var processed = postcss(pxToViewport()).process(rules).css;
expect(processed).toBe(expected);
});
});
describe('minPixelValue', function () {
it('should not replace values below minPixelValue', function () {
var options = {

Loading…
Cancel
Save