Skip to content
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

Properly check if the slider values have changed #879

Merged
merged 3 commits into from Dec 8, 2018

Conversation

jespirit
Copy link
Collaborator

@jespirit jespirit commented Dec 1, 2018

Fixes #878

I'll add unit tests later.

You can check the JSFiddle in the issue.

Pull Requests

Please accompany all pull requests with the following (where appropriate):

  • unit tests (we use Jasmine 2.x.x)
  • JSFiddle (or an equivalent such as CodePen, Plunker, etc) or screenshot/GIF with new feature or bug-fix
  • Link to original Github issue (if this is a bug-fix)
  • Passes CI-server checks (runs automated tests, JS source-code linting, etc..). To run these on your local machine, type grunt test in your Terminal within the bootstrap-slider repository directory

@seiyria
Copy link
Owner

seiyria commented Dec 1, 2018

Good catch!

// FIXME: Setup async event dispatch
// $handle1[0].dispatchEvent(keyboardEvent);
mySlider.handle1Keydown(keyboardEvent);
expect(hasSlideStarted).toBe(true);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this may not work the way you expect it to since the callbacks within the event listeners may not be invoked until the next tick of the event loop.

I would write this test in an async manner using the done callback and just do the assertions within the slideStop event listener and invoke done() on completion

var hasSlideStopped = false;
options.value = [-100, 0];
mySlider = new Slider($('#testSlider1')[0], options);
// $handle1 = $('#mySlider').find('.slider-handle:first');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented code

var mySlider;
var keyboardEvent;
var options;
// var $handle1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented code

@jespirit jespirit force-pushed the issue-878 branch 2 times, most recently from 7a9ba10 to 97fbd5f Compare December 7, 2018 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do not trigger 'change' event when values have not changed
3 participants