-
-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: teehemkay <tmk@exidia.com> Signed-off-by: Anders Kaseorg <andersk@mit.edu>
- Loading branch information
Showing
5 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import path from 'path'; | ||
import test from 'ava'; | ||
import execa from 'execa'; | ||
import tempWrite from 'temp-write'; | ||
import fn from '..'; | ||
|
||
process.chdir(__dirname); | ||
|
||
const main = (arguments_, options) => execa(path.join(__dirname, '../cli-main.js'), arguments_, options); | ||
|
||
const hasUnicornPlugin = config => config.plugins.includes('unicorn'); | ||
const hasPrintConfigGlobal = config => Object.keys(config.globals).includes('printConfig'); | ||
|
||
test('getConfig', async t => { | ||
const filepath = await tempWrite('console.log()\n', 'x.js'); | ||
const options = {filename: filepath, globals: ['printConfig']}; | ||
const result = fn.getConfig(options); | ||
t.true(hasUnicornPlugin(result) && hasPrintConfigGlobal(result)); | ||
}); | ||
|
||
test('print-config option', async t => { | ||
const filepath = await tempWrite('console.log()\n', 'x.js'); | ||
const {stdout} = await main(['--global=printConfig', '--print-config', filepath]); | ||
const result = JSON.parse(stdout); | ||
t.true(hasUnicornPlugin(result) && hasPrintConfigGlobal(result)); | ||
}); |