-
Notifications
You must be signed in to change notification settings - Fork 81
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: extract validation tests, improve test coverage #4093
test: extract validation tests, improve test coverage #4093
Conversation
e289f05
to
561f905
Compare
561f905
to
5c992bf
Compare
it('should pass validation when the field by default', () => { | ||
expect(field.checkValidity()).to.be.true; | ||
expect(field.validate()).to.be.true; | ||
expect(field.invalid).to.be.false; | ||
}); |
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.
note: This is a new test.
it('should not pass validation when the field is required and has no value', () => { | ||
field.required = true; | ||
expect(field.checkValidity()).to.be.false; | ||
expect(field.validate()).to.be.false; | ||
expect(field.invalid).to.be.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.
note: This is a new test.
it('should pass validation when the field is required and has a valid value', () => { | ||
field.required = true; | ||
field.value = '1'; | ||
expect(field.checkValidity()).to.be.true; | ||
expect(field.validate()).to.be.true; | ||
expect(field.invalid).to.be.false; | ||
}); |
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.
note: This is a new test.
it('should update "invalid" state when "required" is removed', () => { | ||
field.required = true; | ||
field.validate(); | ||
expect(field.invalid).to.be.true; | ||
|
||
field.required = false; | ||
expect(field.invalid).to.be.false; | ||
}); |
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.
note: This is a new test.
it('should not update "invalid" when "step" is removed but the field is still required', () => { | ||
field.required = true; | ||
field.step = 2; | ||
field.validate(); | ||
expect(field.invalid).to.be.true; | ||
|
||
field.step = ''; | ||
expect(field.invalid).to.be.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.
note: This is a new test.
Co-authored-by: Serhii Kulykov <iamkulykov@gmail.com>
Kudos, SonarCloud Quality Gate passed!
|
Description
number-field
validation tests into a separate file for the sake of better readability.A preparation for #4095
Type of change
Checklist