-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
test_scroll_zoom_toggler.py
70 lines (58 loc) · 1.93 KB
/
test_scroll_zoom_toggler.py
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
# -*- coding: utf-8 -*-
"""
Test ScrollZoomToggler
----------------------
"""
import folium
from folium import plugins
from folium.utilities import normalize
from jinja2 import Template
def test_scroll_zoom_toggler():
m = folium.Map([45., 3.], zoom_start=4)
szt = plugins.ScrollZoomToggler()
m.add_child(szt)
out = normalize(m._parent.render())
# Verify that the div has been created.
tmpl = Template("""
<img id="{{this.get_name()}}" alt="scroll"
src="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/png/512/arrow-move.png"
style="z-index: 999999"
onclick="{{this._parent.get_name()}}.toggleScroll()"></img>
""")
assert ''.join(tmpl.render(this=szt).split()) in ''.join(out.split())
# Verify that the style has been created
tmpl = Template("""
<style>
#{{this.get_name()}} {
position:absolute;
width:35px;
bottom:10px;
height:35px;
left:10px;
background-color:#fff;
text-align:center;
line-height:35px;
vertical-align: middle;
}
</style>
""")
expected = normalize(tmpl.render(this=szt))
assert expected in out
# Verify that the script is okay.
tmpl = Template("""
{{this._parent.get_name()}}.scrollEnabled = true;
{{this._parent.get_name()}}.toggleScroll = function() {
if (this.scrollEnabled) {
this.scrollEnabled = false;
this.scrollWheelZoom.disable();
} else {
this.scrollEnabled = true;
this.scrollWheelZoom.enable();
}
};
{{this._parent.get_name()}}.toggleScroll();
""")
expected = normalize(tmpl.render(this=szt))
assert expected in out
bounds = m.get_bounds()
assert bounds == [[None, None], [None, None]], bounds