-
Notifications
You must be signed in to change notification settings - Fork 61
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
getConfig will assign default options to generated config #429
base: master
Are you sure you want to change the base?
Conversation
3db8626
to
b0b9bac
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a test.
(thanks for sending a PR!)
src/core/done.js
Outdated
@@ -24,7 +24,7 @@ var done = function() { | |||
var msg = '' | |||
var groupedByFile = {} | |||
var msgGrouped | |||
var group = this.config.groupOutputByFile | |||
var group = 'groupOutputByFile' in this.config ? this.config.groupOutputByFile : true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var group = this.config.groupOutputByFile != null ? this.config.groupOutputByFile : true
82f9cd5
to
0fbea8b
Compare
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. 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
)
} )
} )
Test 1it( 'return complete config when not complete config is passed in', function() {
assert.ok( testConfig.reporter )
} )
Test 2it( 'update config state if passed a valid path', function() {
assert.equal( Object.keys( testConfig ).length, Object.keys( testMethod ).length )
} ) Make sure |
41776ae
to
a190c55
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR, @PalleZingmark ! Just a few, belated comments on this PR for your tests.
var testConfig = JSON.parse( stripJsonComments( fs.readFileSync( process.cwd() + '/.stylintrc', 'utf-8' ) ) ) | ||
var testConfig = app.setConfig( process.cwd() + '/.stylintrc' ) | ||
|
||
it( 'return complete config when not complete config is passed in', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice test! Can we paraphrase a bit to avoid ambiguity with what complete
means here?
Perhaps something like:
it( 'return config with all properties when passed config with missing properties', function() {
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, I'll update the PR. Thnx.
|
||
it( 'update config state if passed a valid path', function() { | ||
assert.deepEqual( testMethod, testConfig ) | ||
assert.equal( Object.keys( testConfig ).length, Object.keys( testMethod ).length ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we changing this test? If we must change this, we should still check for deep equality between two objects since doing key comparisons can lead to false positives.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to remember this one.. 😣
I think I changed it since the important part is that they should contain the same amount of options now, not the exact same values since they may vary. I'll try to dig out my old notes.
Fix for #409