Path: blob/main/tests/plugins/test_scroll_zoom_toggler.py
1601 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"""21<img id="{{this.get_name()}}" alt="scroll"22src="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/png/512/arrow-move.png"23style="z-index: 999999"24onclick="{{this._parent.get_name()}}.toggleScroll()"></img>25"""26)27assert "".join(tmpl.render(this=szt).split()) in "".join(out.split())2829# Verify that the style has been created30tmpl = Template(31"""32<style>33#{{this.get_name()}} {34position:absolute;35width:35px;36bottom:10px;37height:35px;38left:10px;39background-color:#fff;40text-align:center;41line-height:35px;42vertical-align: middle;43}44</style>45"""46)47expected = normalize(tmpl.render(this=szt))48assert expected in out4950# Verify that the script is okay.51tmpl = Template(52"""53{{this._parent.get_name()}}.scrollEnabled = true;5455{{this._parent.get_name()}}.toggleScroll = function() {56if (this.scrollEnabled) {57this.scrollEnabled = false;58this.scrollWheelZoom.disable();59} else {60this.scrollEnabled = true;61this.scrollWheelZoom.enable();62}63};6465{{this._parent.get_name()}}.toggleScroll();66"""67)68expected = normalize(tmpl.render(this=szt))69assert expected in out7071bounds = m.get_bounds()72assert bounds == [[None, None], [None, None]], bounds737475