-
Notifications
You must be signed in to change notification settings - Fork 496
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* remove not used extraArgs feature * use event listener `once` option to remove dragend listener
- Loading branch information
Showing
3 changed files
with
67 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import draggerFactory from '../dragger'; | ||
|
||
/* global sinon */ | ||
|
||
|
||
describe('dragger', function() { | ||
|
||
afterEach(function() { | ||
document.dispatchEvent(new DragEvent('dragend')); | ||
}); | ||
|
||
it('should call provided function on drag event', function() { | ||
|
||
// given | ||
const callbackSpy = sinon.spy(); | ||
const dragger = draggerFactory(callbackSpy); | ||
|
||
// when | ||
dragger(new DragEvent('dragstart')); | ||
|
||
document.dispatchEvent(new DragEvent('drag', { clientX: 1, clientY: 1 })); | ||
|
||
// then | ||
expect(callbackSpy).to.be.calledOnce; | ||
}); | ||
|
||
|
||
it('should not call provided function for last drag event with (0, 0) values', function() { | ||
|
||
// given | ||
const callbackSpy = sinon.spy(); | ||
const dragger = draggerFactory(callbackSpy); | ||
|
||
// when | ||
dragger(new DragEvent('dragstart')); | ||
|
||
document.dispatchEvent(new DragEvent('drag', { clientX: 0, clientY: 0 })); | ||
|
||
// then | ||
expect(callbackSpy).to.not.be.called; | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.