Skip to content

Commit

Permalink
Add test for postcss-nested (issue #19)
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Apr 5, 2021
1 parent e8fede8 commit 08b75a2
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 4 deletions.
45 changes: 45 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -35,7 +35,8 @@
"devDependencies": {
"eslint": "^7.10.0",
"mocha": "^8.1.3",
"postcss": "^8.0.0"
"postcss": "^8.0.0",
"postcss-nested": "^5.0.5"
},
"files": [
"lib",
Expand Down
22 changes: 19 additions & 3 deletions test.js
@@ -1,5 +1,6 @@
const assert = require('assert');
const postcss = require('postcss');
const postcssNested = require('postcss-nested');
const postcssCsso = require('./index.js');

describe('can be used as a postcss plugin', function() {
Expand Down Expand Up @@ -61,23 +62,29 @@ describe('edge cases', function() {
postcssPlugin: 'emptyGenerator',
Once(root) {
const atRule = postcss.atRule({
name: 'test'
name: 'atrule'
});
const rule = postcss.rule();

rule.append(postcss.decl({
prop: 'prop'
}));

root.append(atRule);
root.append(rule);
}
};

return postcss([
emptyGenerator,
postcssCsso
]).process('').then(function(result) {
assert.strictEqual(result.css, '@test;');
assert.strictEqual(result.css, '@atrule;');
});
});
});

it('should keep the shape of original postcss nodes', function() {
it('should keep shape of original postcss nodes', function() {
const css = '.a { p: 1; } .b { p: 2; }';
let count = 0;

Expand Down Expand Up @@ -119,6 +126,15 @@ it('error handling', function() {
});
});

it('should work with postcss-nested (issue #19)', function() {
return postcss([
postcssNested,
postcssCsso
])
.process('.c { .touch &:hover { color: #ff0000; } }')
.then(result => assert.strictEqual(result.css, '.touch .c:hover{color:red}'));
});

// currently works only is used as linked package
// TODO: find the way to use csso compress tests
try {
Expand Down

0 comments on commit 08b75a2

Please sign in to comment.