@@ -180,5 +180,43 @@ describe('Test geo interactions', function() {
180180 } ) ;
181181 } ) ;
182182
183+ describe ( 'trace visibility toggle' , function ( ) {
184+ function countTraces ( type ) {
185+ return d3 . selectAll ( 'g.trace.' + type ) . size ( ) ;
186+ }
187+
188+ it ( 'should toggle scattergeo elements' , function ( done ) {
189+ expect ( countTraces ( 'scattergeo' ) ) . toBe ( 1 ) ;
190+ expect ( countTraces ( 'choropleth' ) ) . toBe ( 1 ) ;
191+
192+ Plotly . restyle ( gd , 'visible' , false , [ 0 ] ) . then ( function ( ) {
193+ expect ( countTraces ( 'scattergeo' ) ) . toBe ( 0 ) ;
194+ expect ( countTraces ( 'choropleth' ) ) . toBe ( 1 ) ;
195+
196+ Plotly . restyle ( gd , 'visible' , true , [ 0 ] ) . then ( function ( ) {
197+ expect ( countTraces ( 'scattergeo' ) ) . toBe ( 1 ) ;
198+ expect ( countTraces ( 'choropleth' ) ) . toBe ( 1 ) ;
199+ done ( ) ;
200+ } ) ;
201+ } ) ;
202+ } ) ;
203+
204+ it ( 'should toggle choropleth elements' , function ( done ) {
205+ expect ( countTraces ( 'scattergeo' ) ) . toBe ( 1 ) ;
206+ expect ( countTraces ( 'choropleth' ) ) . toBe ( 1 ) ;
207+
208+ Plotly . restyle ( gd , 'visible' , false , [ 1 ] ) . then ( function ( ) {
209+ expect ( countTraces ( 'scattergeo' ) ) . toBe ( 1 ) ;
210+ expect ( countTraces ( 'choropleth' ) ) . toBe ( 0 ) ;
211+
212+ Plotly . restyle ( gd , 'visible' , true , [ 1 ] ) . then ( function ( ) {
213+ expect ( countTraces ( 'scattergeo' ) ) . toBe ( 1 ) ;
214+ expect ( countTraces ( 'choropleth' ) ) . toBe ( 1 ) ;
215+ done ( ) ;
216+ } ) ;
217+ } ) ;
218+ } ) ;
219+
220+ } ) ;
183221 } ) ;
184222} ) ;
0 commit comments