offMethodSpec.js 893 B

123456789101112131415161718192021222324252627282930313233
  1. //--------------------------------------------------
  2. //--------------------------------------------------
  3. //-- Removes attached function from slider event --
  4. //--------------------------------------------------
  5. //--------------------------------------------------
  6. describe("'off()' test", function() {
  7. var testSlider, eventHandlerTriggered, mouse;
  8. var onStart = function(){
  9. eventHandlerTriggered = true;
  10. };
  11. beforeEach(function() {
  12. eventHandlerTriggered = false;
  13. mouse = document.createEvent('MouseEvents');
  14. });
  15. it("should properly unbind an event listener", function() {
  16. testSlider = $("#testSlider1").slider();
  17. testSlider.on('slideStart', onStart);
  18. testSlider.off('slideStart', onStart);
  19. testSlider.data('slider')._mousedown(mouse);
  20. expect(eventHandlerTriggered).not.toBeTruthy();
  21. });
  22. });