-
Notifications
You must be signed in to change notification settings - Fork 190
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
[Loom-1535] - add form-test to bpkSlider #3579
Conversation
4d419ca
to
d44f433
Compare
Visit https://backpack.github.io/storybook-prs/3579 to see this build running in a browser. |
ariaLabel={['slider']} | ||
ariaValuetext={['min', 'max']} | ||
data-testid="mySlider" | ||
onChange={(value) => setSliderValue(Array.isArray(value) ? value : [value])} |
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 is the value sometimes within an array and sometimes not?
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.
Because sometimes there aren't a min and max value that could both change and only one side of the slider is changeable. So I wanted one of the tests to check for when both min, max
can change to cover various types. Does that make sense?
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.
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 think I see, so if the sliderValue={[20,80]}
then the bottom "two thumb" slider will be shown?
I think the "two thumb" test case is nice - it's certainly the most complex of the two scenarios. Given that we are in control of the test (and if the slider is two or one) I think we should remove the isArray
code in order to make it clearer what is expected.
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.
so if the sliderValue={[20,80]} then the bottom "two thumb" slider will be shown?
yes that is right!
And okay, I can make it be clear in the description too so there is no confusion for users. :)
expect(handleChange).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it('should emit change event when both sides of slider value are changed', 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.
Nice, I think this test has overlap with "should emit change event when slider value is changed" & thus I think you only need one of them & I think this test is better as it tests both slider value changes.
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 fair!
c113ff1
to
3a0f0f0
Compare
Visit https://backpack.github.io/storybook-prs/3579 to see this build running in a browser. |
3a0f0f0
to
889eeb5
Compare
889eeb5
to
03f4e5a
Compare
Visit https://backpack.github.io/storybook-prs/3579 to see this build running in a browser. |
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 - nice 🎉
Adding a form-test to our slider component to check if it renders correctly.
Remember to include the following changes:
[KOA-123][BpkButton] Updating the colour
README.md
(If you have created a new component)README.md