Skip to content

Commit

Permalink
Merge b5ab7d9 into d58e3a2
Browse files Browse the repository at this point in the history
  • Loading branch information
ertrzyiks committed Sep 26, 2016
2 parents d58e3a2 + b5ab7d9 commit 393c1f3
Show file tree
Hide file tree
Showing 12 changed files with 120 additions and 70 deletions.
21 changes: 21 additions & 0 deletions test/expects/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@import "imports/section.css";

.ComponentName{

color: cyan;

@when stateName{

color: crimson;
}
}

.ComponentName--modifierName{

color: yellow;
}

.ComponentName__descendentName{

color: navy;
}
21 changes: 21 additions & 0 deletions test/expects/custom.sss.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@import "imports/section.sss";;

.ComponentName {

color: cyan;;

@when stateName {

color: crimson;
}
}

.ComponentName--modifierName {

color: yellow;
}

.ComponentName__descendentName {

color: navy;
}
19 changes: 11 additions & 8 deletions test/expects/index.css
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
@import "css/section.css";
@import "imports/section.css";

.index{}
.ComponentName{

.index__test{
color: cyan
}

.ComponentName.is-stateName{

color: blue;
color: crimson
}

.index--test{
.ComponentName--modifierName{

color: red;
color: yellow
}

.index-nested {
.ComponentName-descendentName{

color: goldenrod;
color: navy
}
21 changes: 21 additions & 0 deletions test/expects/index.sss.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@import "imports/section.sss";;

.ComponentName {

color: cyan;
}

.ComponentName.is-stateName {

color: crimson;
}

.ComponentName--modifierName {

color: yellow;
}

.ComponentName-descendentName {

color: navy;
}
17 changes: 0 additions & 17 deletions test/expects/plugins.custom.js

This file was deleted.

5 changes: 0 additions & 5 deletions test/expects/plugins.default.js

This file was deleted.

14 changes: 9 additions & 5 deletions test/fixtures/index.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
@import "imports/section.css";

.index {
@component ComponentName {
color: cyan;

&__test {
color: blue;
@modifier modifierName {
color: yellow;
}

&--test {
color: red;
@descendent descendentName {
color: navy;
}

@when stateName {
color: crimson;
}
}
16 changes: 10 additions & 6 deletions test/fixtures/index.sss
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
@import "imports/section.sss";

.index
color: blue;
@component ComponentName
color: cyan;

.index__red
color: red;
@modifier modifierName
color: yellow;

.index__goldenrod
color: goldenrod;
@descendent descendentName
color: navy;


@when stateName
color: crimson;
42 changes: 20 additions & 22 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,71 +10,69 @@ var fs = require('fs')
var path = require('path')

function fixtures (file) {
return fs.readFileSync(path.join(__dirname, 'fixtures', file))
return fs.readFileSync(path.join(__dirname, 'fixtures', file), 'utf8')
}

function expected (file) {
return fs.readFileSync(path.join(__dirname, 'expects', file))
return fs.readFileSync(path.join(__dirname, 'expects', file), 'utf8')
}

var postcss = require('postcss')
var pluginsrc = require('..')

test('1 - Load with default plugins ', function (t) {
pluginsrc().then(function (plugins) {
t.is(expected('plugins.default.js'), plugins)
return pluginsrc().then(function (plugins) {
t.is(plugins.length, 3)
t.is(plugins[0].postcssPlugin, 'postcss-import')
t.is(plugins[1].postcssPlugin, 'postcss-nested')
t.is(plugins[2].postcssPlugin, 'postcss-bem')
})
})

test('2 - Load with custom plugins ', function (t) {
pluginsrc('postcss.config.js').then(function (plugins) {
t.is(expected('plugins.custom.js'), plugins)
return pluginsrc('postcss.config.js').then(function (plugins) {
t.is(plugins.length, 3)
t.is(plugins[0].postcssPlugin, 'postcss-import')
t.is(plugins[1].postcssPlugin, 'postcss-nested')
t.is(plugins[2].postcssPlugin, 'postcss-bem')
})
})

test('3 - Process CSS with default plugins', function (t) {
pluginsrc().then(function (plugins) {
postcss(plugins)
return pluginsrc().then(function (plugins) {
return postcss(plugins)
.process(fixtures('index.css'))
.then(function (result) {
console.log(result.css)
fs.writeFileSync('expects/index.css', result.css)
t.is(expected('index.css'), result.css)
})
})
})

test('4 - Process SSS with custom plugins', (t) => {
pluginsrc('postcss.config.js').then((plugins) => {
postcss(plugins)
return pluginsrc('postcss.config.js').then((plugins) => {
return postcss(plugins)
.process(fixtures('index.css'))
.then(function (result) {
console.log(result.css)
fs.writeFileSync('expects/custom.css', result.css)
t.is(expected('custom.css'), result.css)
})
})
})

test('5 - Process SSS with default plugins', function (t) {
pluginsrc().then(function (plugins) {
postcss(plugins)
return pluginsrc().then(function (plugins) {
return postcss(plugins)
.process(fixtures('index.sss'), {parser: require('sugarss')})
.then(function (result) {
console.log(result.css)
fs.writeFileSync('expects/index.sss.css', result.css)
t.is(expected('index.sss.css'), result.css)
})
})
})

test('6 - Process SSS with custom plugins', function (t) {
pluginsrc('postcssrc.json').then(function (plugins) {
postcss(plugins)
return pluginsrc('postcssrc.json').then(function (plugins) {
return postcss(plugins)
.process(fixtures('index.sss'), {parser: require('sugarss')})
.then(function (result) {
console.log(result.css)
fs.writeFileSync('expects/custom.sss.css', result.css)
t.is(expected('custom.sss.css'), result.css)
})
})
Expand Down
6 changes: 3 additions & 3 deletions test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
},
"postcss": {
"plugins": {
"postcss-import": false,
"postcss-nested": false,
"postcss-bem": false
"postcss-import": null,
"postcss-nested": null,
"postcss-bem": null
}
}
}
4 changes: 2 additions & 2 deletions test/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
plugins: {
'postcss-import': false,
'postcss-nested': false,
'postcss-import': null,
'postcss-nested': null,
'postcss-bem': {
style: 'bem',
separators: {
Expand Down
4 changes: 2 additions & 2 deletions test/postcssrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"plugins": {
"potscss-import": false,
"postcss-nested": false,
"postcss-import": null,
"postcss-nested": null,
"postcss-bem": {
"style": "bem",
"separators": {
Expand Down

0 comments on commit 393c1f3

Please sign in to comment.