-
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
Add tests for KTextbox
#322
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.
This looks good to me! I did have one question, but I think it's maybe my own confusion around writing tests using 'attribute'. I don't see any issues and all of the tests are passing. Maybe @nucleogenesis can weigh in on if there is anything else he'd like to see, but otherwise looks good to me.
disabled: true, | ||
}, | ||
}); | ||
expect(wrapper.find('input').attributes('disabled')).toBe('disabled'); |
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.
I don't totally understand why this would be 'disabled'
and not a boolean, although the test is passing
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.
disabled
is only boolean by virtue of its presence or absence - that's not always been supported, if I recall correctly, so it's often been conventional to set the value to 'disabled'
.
https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled
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.
TIL it has something to do with xhtml: https://stackoverflow.com/a/6531804
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.
Ahah - thanks for the canonical explanation!
it(`invalidText is not displayed if showInvalidText is false`, () => { | ||
const wrapper = mount(KTextbox, { | ||
propsData: { | ||
invalid: true, | ||
showInvalidText: false, | ||
invalidText: 'error!', | ||
}, | ||
}); | ||
const errorTextField = wrapper.find('.ui-textbox-feedback-text'); | ||
expect(errorTextField.text()).not.toBe('error!'); | ||
}); | ||
it(`invalidText is displayed through error prop if invalid and showInvalidText are both true`, () => { | ||
const wrapper = mount(KTextbox, { | ||
propsData: { | ||
invalid: true, | ||
showInvalidText: true, | ||
invalidText: 'error!', | ||
}, | ||
}); | ||
const errorTextField = wrapper.find('.ui-textbox-feedback-text'); | ||
expect(errorTextField.text()).toBe('error!'); | ||
}); |
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.
I'm so sorry for this weird set of props for handling invalid states but glad to have tests added for it!
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.
This all looks great! Thanks Sairina!
Description
KTextbox
test
folders in KDSchangelog
Issue addressed
Fixes #306
Steps to test
yarn run test
(optional) Implementation notes
At a high level, how did you implement this?
Does this introduce any tech-debt items?
Testing checklist
changelog
Reviewer guidance
Post-merge updates and tracking
Comments