Skip to content

Commit

Permalink
test: refactor using .config.js (JS) for test configs (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored and michael-ciniawsky committed May 10, 2017
1 parent 12c19b9 commit 9785226
Show file tree
Hide file tree
Showing 31 changed files with 115 additions and 94 deletions.
9 changes: 9 additions & 0 deletions test/configs/config.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
file: 'config',
options: {
config: {
path: 'test/fixtures/config/postcss.config.js',
ctx: { plugin: false }
}
}
}
9 changes: 0 additions & 9 deletions test/configs/config.json

This file was deleted.

6 changes: 6 additions & 0 deletions test/configs/error.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
file: 'error',
options: {
parser: 'sugarss'
}
}
6 changes: 0 additions & 6 deletions test/configs/error.json

This file was deleted.

6 changes: 6 additions & 0 deletions test/configs/exec.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
file: 'exec',
options: {
exec: true
}
}
6 changes: 0 additions & 6 deletions test/configs/exec.json

This file was deleted.

8 changes: 8 additions & 0 deletions test/configs/export.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
file: 'export',
options: {
config: {
path: 'test/fixtures/config/postcss.config.js'
}
}
}
8 changes: 0 additions & 8 deletions test/configs/export.json

This file was deleted.

6 changes: 6 additions & 0 deletions test/configs/jss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
file: 'jss',
options: {
parser: 'postcss-js'
}
}
6 changes: 0 additions & 6 deletions test/configs/jss.json

This file was deleted.

9 changes: 9 additions & 0 deletions test/configs/map.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
file: 'map',
options: {
config: {
path: 'test/fixtures'
},
sourceMap: 'inline'
}
}
9 changes: 0 additions & 9 deletions test/configs/map.json

This file was deleted.

8 changes: 8 additions & 0 deletions test/configs/options.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
file: 'options',
options: {
parser: {},
syntax: [],
plugins: {}
}
}
8 changes: 0 additions & 8 deletions test/configs/options.json

This file was deleted.

6 changes: 6 additions & 0 deletions test/configs/parser.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
file: 'parser',
options: {
parser: 'sugarss'
}
}
6 changes: 0 additions & 6 deletions test/configs/parser.json

This file was deleted.

8 changes: 8 additions & 0 deletions test/configs/plugins.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
file: 'plugins',
options: {
plugins: [
require('../plugin')()
]
}
}
8 changes: 8 additions & 0 deletions test/configs/plugins.fn.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
file: 'plugins.fn',
options: {
plugins: () => [
require('../plugin')()
]
}
}
4 changes: 4 additions & 0 deletions test/configs/plugins.fn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
test('Plugins - {Function}', () => {
const css = require('../fixtures/style.css')
expect(css).toEqual('a { color: rgba(255, 0, 0, 1.0) }\n')
})
6 changes: 0 additions & 6 deletions test/configs/plugins.json

This file was deleted.

9 changes: 9 additions & 0 deletions test/configs/sourceMap-inline.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
file: 'sourceMap-inline',
options: {
config: {
path: 'test/fixtures/config/postcss.config.js'
},
sourceMap: 'inline'
}
}
4 changes: 4 additions & 0 deletions test/configs/sourceMap-inline.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
test('Source Maps - Inline', () => {
const css = require('../fixtures/style.css')
expect(css).toEqual('a { color: black }\n\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxlLmNzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxJQUFJLFlBQVksRUFBRSIsImZpbGUiOiJzdHlsZS5jc3MiLCJzb3VyY2VzQ29udGVudCI6WyJhIHsgY29sb3I6IGJsYWNrIH1cbiJdfQ== */')
})
9 changes: 9 additions & 0 deletions test/configs/sourceMap-true.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
file: 'sourceMap-true',
options: {
config: {
path: 'test/fixtures/config/postcss.config.js'
},
sourceMap: true
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test('Source Maps', () => {
test('Source Maps - true', () => {
const css = require('../fixtures/style.css')
expect(css).toEqual('a { color: black }\n')
})
9 changes: 0 additions & 9 deletions test/configs/sourceMap.json

This file was deleted.

6 changes: 6 additions & 0 deletions test/configs/stringifier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
file: 'stringifier',
options: {
stringifier: 'sugarss'
}
}
6 changes: 0 additions & 6 deletions test/configs/stringifier.json

This file was deleted.

6 changes: 6 additions & 0 deletions test/configs/syntax.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
file: 'syntax',
options: {
syntax: 'sugarss'
}
}
6 changes: 0 additions & 6 deletions test/configs/syntax.json

This file was deleted.

4 changes: 2 additions & 2 deletions test/webpack.build.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ const builds = path.join(__dirname, 'builds')
if (fs.existsSync(builds)) fs.remove(builds)

fs.readdirSync(path.join(__dirname, 'configs'))
.filter((file) => path.extname(file) === '.json')
.filter((file) => path.extname(file) === '.js' && path.extname(path.basename(file, '.js')) === '.config')
.forEach((config) => {
config = fs.readFileSync(path.join(__dirname, 'configs', config), 'utf8')
config = require(path.join(__dirname, 'configs', config))
config = require(path.join(__dirname, 'webpack.config.js'))(config)

webpack(config, () => {})
Expand Down
6 changes: 0 additions & 6 deletions test/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
const path = require('path')

module.exports = (config) => {
config = JSON.parse(config)

if (config.options && config.options.plugins) {
config.options.plugins = [ require('./plugin')() ]
}

return {
target: 'node',
devtool: 'source-map',
Expand Down

0 comments on commit 9785226

Please sign in to comment.