Skip to content

test: refactor using .config.js (JS) for test configs #230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sourceMap-inline => map ( Referring to PostCSS { map: 'inline'})

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michael-ciniawsky Will not it be a bit confused?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah... 🙃 😛 I just don't like the dash style :D

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',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sourceMap-true => sourceMap

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michael-ciniawsky i think we late add sourceMap - false

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', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- true

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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