MadLittleMods / postcss-css-variables

PostCSS plugin to transform CSS Custom Properties(CSS variables) syntax into a static representation
https://madlittlemods.github.io/postcss-css-variables/playground/
Other
536 stars 62 forks source link

Providing undefined as a string #44

Closed vincentorback closed 7 years ago

vincentorback commented 7 years ago

Fix #22

This resolves the issues I was testing in #22 where an undefined variable broke other plugins by providing an undefined variable instead of a variable with the value of "undefined".

Don’t really know what tests to add because the output will be the same in this plugin context. But if you have an idea I could add something! 👍

MadLittleMods commented 7 years ago

@vincentorback Thanks for the PR 😀

The output string will be the same but we can look ast tree and check the type of the value on that node.

var chai = require('chai');
var expect = chai.expect;

var postcss = require('postcss');
var cssvariables = require('postcss-css-variables');

var fs = require('fs');

var mycss = fs.readFileSync('input.css', 'utf8');

describe('postcss-css-variables', function() {
  it('Should use string values for `undefined` values, see #22', function() {
    return postcss([
        cssvariables(/*options*/)
      ])
      .process(mycss)
      .then(function(result) {
        var root = result.root;
        var fooRule = root.nodes[0];
        expect(fooRule.selector).to.equal('.foo');
        var colorDecl = fooRule.nodes[0];
        expect(colorDecl.value).to.be.a('string');
      });
  });
});
vincentorback commented 7 years ago

Updated with new undefined check + new comment! What was the extra whitespace you commented on?

MadLittleMods commented 7 years ago

@vincentorback You can expand the past dismissed comments.

Let's add in the test I mentioned earlier.

vincentorback commented 7 years ago

I added a test but I’m really new to mocha so take a look if I should change something.

MadLittleMods commented 7 years ago

After fixing up these last points, squash down the commits please

vincentorback commented 7 years ago

I think that’s it!

MadLittleMods commented 7 years ago

@vincentorback Thanks for sorting out the last bits. Will take a look soon 😀

MadLittleMods commented 7 years ago

@vincentorback This has been merged in and released in v0.6.0 and published on npm. Thanks again for the contribution :revolving_hearts: