Path: blob/main/tests/plugins/test_scroll_zoom_toggler.py
2533 views
"""1Test ScrollZoomToggler2----------------------3"""45import folium6from folium import plugins7from folium.template import Template8from folium.utilities import normalize91011def test_scroll_zoom_toggler():12m = folium.Map([45.0, 3.0], zoom_start=4)13szt = plugins.ScrollZoomToggler()14m.add_child(szt)1516out = normalize(m._parent.render())1718# Verify that the div has been created.19tmpl = Template("""20<img id="{{this.get_name()}}" alt="scroll"21src="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/png/512/arrow-move.png"22style="z-index: 999999"23onclick="{{this._parent.get_name()}}.toggleScroll()"></img>24""")25assert "".join(tmpl.render(this=szt).split()) in "".join(out.split())2627# Verify that the style has been created28tmpl = Template("""29<style>30#{{this.get_name()}} {31position:absolute;32width:35px;33bottom:10px;34height:35px;35left:10px;36background-color:#fff;37text-align:center;38line-height:35px;39vertical-align: middle;40}41</style>42""")43expected = normalize(tmpl.render(this=szt))44assert expected in out4546# Verify that the script is okay.47tmpl = Template("""48{{this._parent.get_name()}}.scrollEnabled = true;4950{{this._parent.get_name()}}.toggleScroll = function() {51if (this.scrollEnabled) {52this.scrollEnabled = false;53this.scrollWheelZoom.disable();54} else {55this.scrollEnabled = true;56this.scrollWheelZoom.enable();57}58};5960{{this._parent.get_name()}}.toggleScroll();61""")62expected = normalize(tmpl.render(this=szt))63assert expected in out6465bounds = m.get_bounds()66assert bounds == [[None, None], [None, None]], bounds676869