forked from ionic-team/ionic-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathionicGesture.unit.js
48 lines (35 loc) · 1.15 KB
/
ionicGesture.unit.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
describe('Ionic Gesture Service', function() {
var gesture;
beforeEach(module('ionic.service.gesture'));
beforeEach(inject(function($ionicGesture) {
gesture = $ionicGesture;
}));
it('Should bind', function() {
var el = document.createElement('div');
var handlers = {
dragHandle: function(e) {
}
};
spyOn(handlers, 'dragHandle');
gesture.on('drag', handlers.dragHandle, angular.element(el));
var event = new CustomEvent('drag', { target: el });
el.dispatchEvent(event);
expect(handlers.dragHandle).toHaveBeenCalled();
});
it('Should unbind', function() {
var el = document.createElement('div');
var handlers = {
dragHandle: function(e) {
}
};
spyOn(handlers, 'dragHandle');
var g = gesture.on('drag', handlers.dragHandle, angular.element(el));
var event = new CustomEvent('drag', { target: el });
el.dispatchEvent(event);
expect(handlers.dragHandle).toHaveBeenCalled();
gesture.off(g, 'drag', handlers.dragHandle);
event = new CustomEvent('drag', { target: el });
el.dispatchEvent(event);
expect(handlers.dragHandle).toHaveBeenCalled();
});
});