Closed jespirit closed 5 years ago
Added some unit test coverage that codeclimate wouldn't be too happy about it.
My unit tests before fix:
Of course, then there's RTL and different positions of the tooltip... etc.
I added more unit tests for displaying tooltips for a vertical slider.
My unit tests before fix:
Codeclimate would be really unhappy. I essentially copied the same code for the horizontal slider except I changed the offsetLeft
to be offsetTop
.
Codeclimate would be really unhappy. I essentially copied the same code for the horizontal slider except I changed the offsetLeft to be offsetTop.
Did you copy / paste for the unit tests? I don't really care about that TBH. if its too difficult to refactor into a sensible DRY format, then its not worth the hassle. Biggest thing is that we have test coverage on all potential cases + any bugs that arise so that we can prevent regressions.
I copied and pasted more unit tests. You can check the commits.
I don't think I can refactor that stuff. I could try? It was hard to manage. One mistake and I had to change other parts of the code =(
I did notice that the ClientX
and ClientY
values are just ignored when dispatching mouseenter
events when I was writing the tests for when hovering over the handles. I could probably (?) just get rid of the offsets entirely when using mouseenter
for the other tests.
As per your request/challenge I refactored the code.
I tried to use as many variables as I can and moved as much initialization code inside beforeEach()
functions.
In fact, I just copied all the tooltip unit tests and changed a few variables to test against the RTL slider.
Before my fix:
Good luck, trying to maintain that code!
LGTM 👍
I refactored the unit tests so it's easier to manage.
Fixes #884
This displays the correct value for the tick and correctly positions the tooltip above the tick.
Will add unit tests.
Pull Requests
Please accompany all pull requests with the following (where appropriate):
grunt test
in your Terminal within the bootstrap-slider repository directory