21
21
)
22
22
}
23
23
24
+
25
+ resize_code_strings = [
26
+ 'window.addEventListener("resize", ' ,
27
+ 'Plotly.Plots.resize('
28
+ ]
29
+
30
+
24
31
PLOTLYJS = plotly .offline .offline .get_plotlyjs ()
25
32
26
33
@@ -77,10 +84,7 @@ def test_div_output(self):
77
84
self .assertTrue (html .startswith ('<div>' ) and html .endswith ('</div>' ))
78
85
79
86
def test_autoresizing (self ):
80
- resize_code_strings = [
81
- 'window.addEventListener("resize", ' ,
82
- 'Plotly.Plots.resize('
83
- ]
87
+
84
88
# If width or height wasn't specified, then we add a window resizer
85
89
html = self ._read_html (plotly .offline .plot (fig , auto_open = False ))
86
90
for resize_code_string in resize_code_strings :
@@ -96,6 +100,28 @@ def test_autoresizing(self):
96
100
for resize_code_string in resize_code_strings :
97
101
self .assertNotIn (resize_code_string , html )
98
102
103
+ def test_autoresizing_div (self ):
104
+
105
+ # If width or height wasn't specified, then we add a window resizer
106
+ for include_plotlyjs in [True , False ]:
107
+ html = plotly .offline .plot (fig ,
108
+ output_type = 'div' ,
109
+ include_plotlyjs = include_plotlyjs )
110
+
111
+ for resize_code_string in resize_code_strings :
112
+ self .assertIn (resize_code_string , html )
113
+
114
+ # If width or height was specified, then we don't resize
115
+ html = plotly .offline .plot ({
116
+ 'data' : fig ['data' ],
117
+ 'layout' : {
118
+ 'width' : 500 , 'height' : 500
119
+ }
120
+ }, output_type = 'div' )
121
+
122
+ for resize_code_string in resize_code_strings :
123
+ self .assertNotIn (resize_code_string , html )
124
+
99
125
def test_config (self ):
100
126
config = dict (linkText = 'Plotly rocks!' ,
101
127
editable = True )
0 commit comments