-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
chore: remove underscores from private properties and methods in some fields #6977
chore: remove underscores from private properties and methods in some fields #6977
Conversation
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.
LGTM! Just one question about whether the click handler tests are doing anything for us.
test('JS Constructor', function() { | ||
const field = new Blockly.FieldImage('src', 10, 10, null, this.onClick); | ||
chai.assert.equal(field.clickHandler_, this.onClick); | ||
chai.assert.equal(field.clickHandler, this.onClick); | ||
}); | ||
test('setOnClickHandler', function() { | ||
const field = new Blockly.FieldImage('src', 10, 10); | ||
field.setOnClickHandler(this.onClick); | ||
chai.assert.equal(field.clickHandler_, this.onClick); | ||
chai.assert.equal(field.clickHandler, this.onClick); | ||
}); | ||
test('Remove Click Handler', function() { | ||
const field = new Blockly.FieldImage('src', 10, 10, null, this.onClick); | ||
field.setOnClickHandler(null); | ||
chai.assert.isNull(field.clickHandler_); | ||
chai.assert.isNull(field.clickHandler); | ||
}); |
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.
Honestly not sure if these tests are worth maintaining given that setOnClickHandler
literally just assigns a variable. (costs of doing updates like this might not be worth the benefits)
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.
Yeah. It's testing all of the arguments, but not in a super useful way.
I've been taking notes as I changed fields, and this is a pattern across the field tests. I think the solution is to test that the click handler is actually getting called (possibly using the stuff Eric is working on?) and then delete the tests that check whether the property was set.
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.
But it is testing that all ways of constructing this particular type of field work exactly the same, and I think that coverage is worthwhile. I'd like to preserve that, just in a way that doesn't pry inside the field so aggressively.
The basics
npm run format
andnpm run lint
The details
Resolves
Part of #6548
Proposed Changes
Remove underscores from private property and method names. Fix uses in tests. In some cases, update tests to use existing getters.