Open PalleZingmark opened 6 years ago
Looking into writing tests for this, I actually get some weird output (on master
) which to me looks a bit unintended within the test. Is this a bug or intended behaviour?
I need to update tests.
@PalleZingmark not so much intended as known 🙂 Fixed in v2, FWIW
Updated tests according to the approach discussed in #409. Here's my thoughts on the tests:
describe( 'Set Config should:', function() {
process.argv[2] = '-c'
process.argv[3] = '.stylintrc'
var testMethod = app.setConfig( '.stylintrc' )
var testConfig = app.setConfig( process.cwd() + '/.stylintrc' )
it( 'return complete config when not complete config is passed in', function() {
assert.ok( testConfig.reporter )
} )
it( 'update config state if passed a valid path', function() {
assert.equal( Object.keys( testConfig ).length, Object.keys( testMethod ).length )
} )
it( 'throw if passed invalid path', function() {
assert.throws(
app.setConfig,
TypeError,
'setConfig err. Expected string, but received: ' + typeof dir
)
} )
} )
testMethod
: Contains a config generated based on the default config options.
testConfig
: Contains a config for test, generated on a .stylintrc that doesn't contain a full set of options.
it( 'return complete config when not complete config is passed in', function() {
assert.ok( testConfig.reporter )
} )
setConfig()
should return a config with the reporter
-option included even though it's not part of the actual .stylintrc file passed to the function.
it( 'update config state if passed a valid path', function() {
assert.equal( Object.keys( testConfig ).length, Object.keys( testMethod ).length )
} )
Make sure setConfig
returns just as many options as testMethod
even though the actual .stylintrc file passed to the function contains fever options.
Fix for #409