@@ -8,6 +8,7 @@ var d3 = require('d3');
8
8
var createGraphDiv = require ( '../assets/create_graph_div' ) ;
9
9
var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
10
10
var mouseEvent = require ( '../assets/mouse_event' ) ;
11
+ var failTest = require ( '../assets/fail_test' ) ;
11
12
12
13
var customAssertions = require ( '../assets/custom_assertions' ) ;
13
14
var assertHoverLabelStyle = customAssertions . assertHoverLabelStyle ;
@@ -175,7 +176,7 @@ describe('Test choropleth hover:', function() {
175
176
} ) ;
176
177
} ) ;
177
178
178
- describe ( 'choropleth bad data ' , function ( ) {
179
+ describe ( 'choropleth drawing ' , function ( ) {
179
180
var gd ;
180
181
181
182
beforeEach ( function ( ) {
@@ -196,7 +197,38 @@ describe('choropleth bad data', function() {
196
197
// only utopia logs - others are silently ignored
197
198
expect ( Lib . log ) . toHaveBeenCalledTimes ( 1 ) ;
198
199
} )
199
- . catch ( fail )
200
+ . catch ( failTest )
201
+ . then ( done ) ;
202
+ } ) ;
203
+
204
+ it ( 'preserves order after hide/show' , function ( done ) {
205
+ function getIndices ( ) {
206
+ var out = [ ] ;
207
+ d3 . selectAll ( '.choropleth' ) . each ( function ( d ) { out . push ( d [ 0 ] . trace . index ) ; } ) ;
208
+ return out ;
209
+ }
210
+
211
+ Plotly . newPlot ( gd , [ {
212
+ type : 'choropleth' ,
213
+ locations : [ 'CAN' , 'USA' ] ,
214
+ z : [ 1 , 2 ]
215
+ } , {
216
+ type : 'choropleth' ,
217
+ locations : [ 'CAN' , 'USA' ] ,
218
+ z : [ 2 , 1 ]
219
+ } ] )
220
+ . then ( function ( ) {
221
+ expect ( getIndices ( ) ) . toEqual ( [ 0 , 1 ] ) ;
222
+ return Plotly . restyle ( gd , 'visible' , false , [ 0 ] ) ;
223
+ } )
224
+ . then ( function ( ) {
225
+ expect ( getIndices ( ) ) . toEqual ( [ 1 ] ) ;
226
+ return Plotly . restyle ( gd , 'visible' , true , [ 0 ] ) ;
227
+ } )
228
+ . then ( function ( ) {
229
+ expect ( getIndices ( ) ) . toEqual ( [ 0 , 1 ] ) ;
230
+ } )
231
+ . catch ( failTest )
200
232
. then ( done ) ;
201
233
} ) ;
202
234
} ) ;
0 commit comments