Skip to content

Commit bd68381

Browse files
committed
Better config tests
1 parent 073882e commit bd68381

2 files changed

Lines changed: 28 additions & 4 deletions

File tree

test/config.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import ENV from './helpers/env.js'
55

66
import cli from './helpers/cli.js'
77
import read from './helpers/read.js'
8+
import tmp from './helpers/tmp.js'
89

910
test('supports common config', async (t) => {
1011
const env = `module.exports = {
@@ -13,10 +14,10 @@ test('supports common config', async (t) => {
1314
]
1415
}`
1516

16-
const dir = await ENV(env, ['a.css'])
17+
const dir = await ENV(env, ['import.css', 'a.css'])
1718

1819
const { error, stderr } = await cli(
19-
['a.css', '-o', 'output.css', '--no-map'],
20+
['import.css', '-o', 'output.css', '--no-map'],
2021
dir,
2122
)
2223

@@ -38,10 +39,10 @@ test('supports ESM config', async (t) => {
3839
}
3940
}`
4041

41-
const dir = await ENV(env, ['a.css'], 'mjs')
42+
const dir = await ENV(env, ['import.css', 'a.css'], 'mjs')
4243

4344
const { error, stderr } = await cli(
44-
['a.css', '-o', 'output.css', '--no-map'],
45+
['import.css', '-o', 'output.css', '--no-map'],
4546
dir,
4647
)
4748

@@ -100,3 +101,20 @@ test('errors if `from` is set', async (t) => {
100101
/Config Error: Can not set from or to options in config file, use CLI arguments instead/,
101102
)
102103
})
104+
105+
test('supports --config flag', async (t) => {
106+
const output = tmp('output.css')
107+
108+
const { error, stderr } = await cli([
109+
'test/fixtures/import.css',
110+
'-o',
111+
output,
112+
'--no-map',
113+
'--config',
114+
'test/fixtures/cfg-dir',
115+
])
116+
117+
t.falsy(error, stderr)
118+
119+
t.is(await read(output), await read('test/fixtures/a.css'))
120+
})
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import postcssImport from 'postcss-import'
2+
export default function () {
3+
return {
4+
plugins: [postcssImport()],
5+
}
6+
}

0 commit comments

Comments
 (0)