forked from ionic-team/ionic-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscrollViewNative.unit.js
More file actions
72 lines (63 loc) · 2 KB
/
scrollViewNative.unit.js
File metadata and controls
72 lines (63 loc) · 2 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
describe('Scroll View', function() {
var sc;
beforeEach(function() {
sc = document.createElement('scroll-content');
s = document.createElement('scroll');
sc.appendChild(s);
});
it('Should init', function() {
var sv = new ionic.views.ScrollNative({
el: sc
});
});
it('Should be frozen after calling freeze', function(){
var sv = new ionic.views.ScrollNative({
el: sc
});
sv.freeze(true);
expect(sv.__frozen).toEqual(true);
sv.freeze(false);
expect(sv.__frozen).toEqual(false);
});
it('Should be frozen shut after calling freezeShut', function(){
var sv = new ionic.views.ScrollNative({
el: sc
});
sv.freezeShut(true);
expect(sv.__frozenShut).toEqual(true);
sv.freezeShut(false);
expect(sv.__frozenShut).toEqual(false);
});
it('Should shut down event completely when view is frozen shut', function(){
var sv = new ionic.views.ScrollNative({
el: sc
});
sv.freezeShut(true);
var mockEvent = {
preventDefault: jasmine.createSpy(),
stopPropagation: jasmine.createSpy()
};
var result = sv.handleTouchMove(mockEvent);
expect(result).toEqual(false);
expect(mockEvent.preventDefault).toHaveBeenCalled();
expect(mockEvent.stopPropagation).toHaveBeenCalled();
expect(mockEvent.preventDefault.callCount).toEqual(1);
expect(mockEvent.stopPropagation.callCount).toEqual(1);
});
it('Should prevent default on event when view is frozen', function(){
var sv = new ionic.views.ScrollNative({
el: sc
});
sv.freeze(true);
var mockEvent = {
preventDefault: jasmine.createSpy(),
stopPropagation: jasmine.createSpy()
};
var result = sv.handleTouchMove(mockEvent);
expect(result).toEqual(false);
expect(mockEvent.preventDefault).toHaveBeenCalled();
expect(mockEvent.stopPropagation).not.toHaveBeenCalled();
expect(mockEvent.preventDefault.callCount).toEqual(1);
expect(mockEvent.stopPropagation.callCount).toEqual(0);
});
});