-
Notifications
You must be signed in to change notification settings - Fork 86
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
test: cleanup text-field unit tests covered by mixins tests #8715
Conversation
}); | ||
}); | ||
|
||
describe('binding', () => { |
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.
All tests in this suite are covered here:
describe('value', () => { |
}); | ||
}); | ||
|
||
describe('has-value attribute', () => { |
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.
Moved tests for number and boolean to this suite, others are already covered:
describe('value', () => { |
}); | ||
}); | ||
|
||
describe(`methods`, () => { |
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.
Both tests in this suite are covered here:
describe('value', () => { |
await assertAttrCanBeSet(prop, true); | ||
await assertAttrCanBeSet(prop, false); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('clear button', () => { |
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.
Moved the default value test to this suite, all the rest are already covered there:
describe('basic', () => { |
@@ -159,74 +99,5 @@ describe('text-field', () => { | |||
expect(textField.hasAttribute('focused')).to.be.true; | |||
}); | |||
}); | |||
|
|||
describe('autoselect', () => { |
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.
Moved two tests to this suite:
describe('autoselect', () => { |
8c3ee54
to
7750b0e
Compare
fire(input, 'input'); | ||
expect(textField.value).to.be.equal('foo'); | ||
it('should set ariaTarget property to the input element', () => { | ||
expect(textField.ariaTarget).to.equal(textField.inputElement); |
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.
The ariaTarget
property was not covered at all (tests passed with it being removed).
I also added explicit tests for focusElement
and stateTarget
for consistency.
|
['disabled'].forEach((prop) => { | ||
it(`should set boolean property ${prop}`, async () => { |
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.
Covered here:
it('should propagate disabled property to the input', () => { |
}); | ||
}); | ||
|
||
['autocomplete', 'autocorrect', 'readonly', 'required'].forEach((prop) => { |
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.
Covered here:
describe('readonly', () => { |
describe('required', () => { |
['autocomplete'].forEach((prop) => { | ||
it(`should set boolean attribute ${prop}`, async () => { | ||
await assertAttrCanBeSet(prop, 'on'); | ||
}); | ||
}); | ||
|
||
['autocapitalize'].forEach((prop) => { |
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.
Covered here:
describe('properties', () => { |
This ticket/PR has been released with Vaadin 24.7.0.alpha12 and is also targeting the upcoming stable 24.7.0 version. |
Description
The following unit tests are now covered by mixins, and we have
typings
tests that ensure the text field does apply them:autoselect
- covered byInputControlMixin
clearButtonVisible
- covered byClearButtonMixin
binding
(value) - covered byInputMixin
clear()
method - covered byInputMixin
Also the property delegation logic was moved to mixins:
disabled
property - covered byDelegateFocusMixin
autocorrect
,autocomplete
,autocapitalize
- covered byInputFieldMixin
placeholder
,readonly
,required
,title
- covered byInputControlMixin
IMO having these tests only in
@vaadin/text-field
package is not necessary. In particular, they are not present in other field components that use same mixins e.g.@vaadin/number-field
- in V14, this component was based on text-field but it's no longer the case.Note: since we don't have JS API to test that the component uses certain mixins (see #2357), we have to rely on the typings tests, which is not ideal. However, this would only break the component if some mixins are changed in
.js
but not in.d.ts
which would be an issue on its own. So IMO we can rely on typings tests for now.Type of change