diff --git a/test/configs/config.config.js b/test/configs/config.config.js new file mode 100644 index 00000000..a6246564 --- /dev/null +++ b/test/configs/config.config.js @@ -0,0 +1,9 @@ +module.exports = { + file: 'config', + options: { + config: { + path: 'test/fixtures/config/postcss.config.js', + ctx: { plugin: false } + } + } +} diff --git a/test/configs/config.json b/test/configs/config.json deleted file mode 100644 index 10ccd687..00000000 --- a/test/configs/config.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "file": "config", - "options": { - "config": { - "path": "test/fixtures/config/postcss.config.js", - "ctx": { "plugin": false } - } - } -} diff --git a/test/configs/error.config.js b/test/configs/error.config.js new file mode 100644 index 00000000..546e53c6 --- /dev/null +++ b/test/configs/error.config.js @@ -0,0 +1,6 @@ +module.exports = { + file: 'error', + options: { + parser: 'sugarss' + } +} diff --git a/test/configs/error.json b/test/configs/error.json deleted file mode 100644 index b09fb918..00000000 --- a/test/configs/error.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "file": "error", - "options": { - "parser": "sugarss" - } -} diff --git a/test/configs/exec.config.js b/test/configs/exec.config.js new file mode 100644 index 00000000..edcc7bd1 --- /dev/null +++ b/test/configs/exec.config.js @@ -0,0 +1,6 @@ +module.exports = { + file: 'exec', + options: { + exec: true + } +} diff --git a/test/configs/exec.json b/test/configs/exec.json deleted file mode 100644 index 0c07dd74..00000000 --- a/test/configs/exec.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "file": "exec", - "options": { - "exec": true - } -} diff --git a/test/configs/export.config.js b/test/configs/export.config.js new file mode 100644 index 00000000..f9183a8f --- /dev/null +++ b/test/configs/export.config.js @@ -0,0 +1,8 @@ +module.exports = { + file: 'export', + options: { + config: { + path: 'test/fixtures/config/postcss.config.js' + } + } +} diff --git a/test/configs/export.json b/test/configs/export.json deleted file mode 100644 index dce71c49..00000000 --- a/test/configs/export.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "file": "export", - "options": { - "config": { - "path": "test/fixtures/config/postcss.config.js" - } - } -} diff --git a/test/configs/jss.config.js b/test/configs/jss.config.js new file mode 100644 index 00000000..a623a8d5 --- /dev/null +++ b/test/configs/jss.config.js @@ -0,0 +1,6 @@ +module.exports = { + file: 'jss', + options: { + parser: 'postcss-js' + } +} diff --git a/test/configs/jss.json b/test/configs/jss.json deleted file mode 100644 index c971af37..00000000 --- a/test/configs/jss.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "file": "jss", - "options": { - "parser": "postcss-js" - } -} diff --git a/test/configs/map.config.js b/test/configs/map.config.js new file mode 100644 index 00000000..939a4cb8 --- /dev/null +++ b/test/configs/map.config.js @@ -0,0 +1,9 @@ +module.exports = { + file: 'map', + options: { + config: { + path: 'test/fixtures' + }, + sourceMap: 'inline' + } +} diff --git a/test/configs/map.json b/test/configs/map.json deleted file mode 100644 index ba535545..00000000 --- a/test/configs/map.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "file": "map", - "options": { - "config": { - "path": "test/fixtures" - }, - "sourceMap": "inline" - } -} diff --git a/test/configs/options.config.js b/test/configs/options.config.js new file mode 100644 index 00000000..c5078019 --- /dev/null +++ b/test/configs/options.config.js @@ -0,0 +1,8 @@ +module.exports = { + file: 'options', + options: { + parser: {}, + syntax: [], + plugins: {} + } +} diff --git a/test/configs/options.json b/test/configs/options.json deleted file mode 100644 index 55b9f36e..00000000 --- a/test/configs/options.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "file": "options", - "options": { - "parser": {}, - "syntax": [], - "plugins": {} - } -} diff --git a/test/configs/parser.config.js b/test/configs/parser.config.js new file mode 100644 index 00000000..f0848776 --- /dev/null +++ b/test/configs/parser.config.js @@ -0,0 +1,6 @@ +module.exports = { + file: 'parser', + options: { + parser: 'sugarss' + } +} diff --git a/test/configs/parser.json b/test/configs/parser.json deleted file mode 100644 index 9df7d574..00000000 --- a/test/configs/parser.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "file": "parser", - "options": { - "parser": "sugarss" - } -} diff --git a/test/configs/plugins.config.js b/test/configs/plugins.config.js new file mode 100644 index 00000000..f62da8a4 --- /dev/null +++ b/test/configs/plugins.config.js @@ -0,0 +1,8 @@ +module.exports = { + file: 'plugins', + options: { + plugins: [ + require('../plugin')() + ] + } +} diff --git a/test/configs/plugins.fn.config.js b/test/configs/plugins.fn.config.js new file mode 100644 index 00000000..706e15ef --- /dev/null +++ b/test/configs/plugins.fn.config.js @@ -0,0 +1,8 @@ +module.exports = { + file: 'plugins.fn', + options: { + plugins: () => [ + require('../plugin')() + ] + } +} diff --git a/test/configs/plugins.fn.js b/test/configs/plugins.fn.js new file mode 100644 index 00000000..ab1a5337 --- /dev/null +++ b/test/configs/plugins.fn.js @@ -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') +}) diff --git a/test/configs/plugins.json b/test/configs/plugins.json deleted file mode 100644 index f87fa371..00000000 --- a/test/configs/plugins.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "file": "plugins", - "options": { - "plugins": true - } -} diff --git a/test/configs/sourceMap-inline.config.js b/test/configs/sourceMap-inline.config.js new file mode 100644 index 00000000..164fa621 --- /dev/null +++ b/test/configs/sourceMap-inline.config.js @@ -0,0 +1,9 @@ +module.exports = { + file: 'sourceMap-inline', + options: { + config: { + path: 'test/fixtures/config/postcss.config.js' + }, + sourceMap: 'inline' + } +} diff --git a/test/configs/sourceMap-inline.js b/test/configs/sourceMap-inline.js new file mode 100644 index 00000000..1c9fb04b --- /dev/null +++ b/test/configs/sourceMap-inline.js @@ -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== */') +}) diff --git a/test/configs/sourceMap-true.config.js b/test/configs/sourceMap-true.config.js new file mode 100644 index 00000000..1ef81ab9 --- /dev/null +++ b/test/configs/sourceMap-true.config.js @@ -0,0 +1,9 @@ +module.exports = { + file: 'sourceMap-true', + options: { + config: { + path: 'test/fixtures/config/postcss.config.js' + }, + sourceMap: true + } +} diff --git a/test/configs/sourceMap.js b/test/configs/sourceMap-true.js similarity index 73% rename from test/configs/sourceMap.js rename to test/configs/sourceMap-true.js index d6398d98..44e4079b 100644 --- a/test/configs/sourceMap.js +++ b/test/configs/sourceMap-true.js @@ -1,4 +1,4 @@ -test('Source Maps', () => { +test('Source Maps - true', () => { const css = require('../fixtures/style.css') expect(css).toEqual('a { color: black }\n') }) diff --git a/test/configs/sourceMap.json b/test/configs/sourceMap.json deleted file mode 100644 index a245f5f7..00000000 --- a/test/configs/sourceMap.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "file": "sourceMap", - "options": { - "config": { - "path": "test/fixtures/config/postcss.config.js" - }, - "sourceMap": true - } -} diff --git a/test/configs/stringifier.config.js b/test/configs/stringifier.config.js new file mode 100644 index 00000000..5edf499e --- /dev/null +++ b/test/configs/stringifier.config.js @@ -0,0 +1,6 @@ +module.exports = { + file: 'stringifier', + options: { + stringifier: 'sugarss' + } +} diff --git a/test/configs/stringifier.json b/test/configs/stringifier.json deleted file mode 100644 index 47f06f81..00000000 --- a/test/configs/stringifier.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "file": "stringifier", - "options": { - "stringifier": "sugarss" - } -} diff --git a/test/configs/syntax.config.js b/test/configs/syntax.config.js new file mode 100644 index 00000000..5265a8be --- /dev/null +++ b/test/configs/syntax.config.js @@ -0,0 +1,6 @@ +module.exports = { + file: 'syntax', + options: { + syntax: 'sugarss' + } +} diff --git a/test/configs/syntax.json b/test/configs/syntax.json deleted file mode 100644 index 83ac0874..00000000 --- a/test/configs/syntax.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "file": "syntax", - "options": { - "syntax": "sugarss" - } -} diff --git a/test/webpack.build.js b/test/webpack.build.js index 98631156..443b24b2 100644 --- a/test/webpack.build.js +++ b/test/webpack.build.js @@ -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, () => {}) diff --git a/test/webpack.config.js b/test/webpack.config.js index a90b2dfa..faae2ec6 100644 --- a/test/webpack.config.js +++ b/test/webpack.config.js @@ -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',