@@ -292,9 +292,23 @@ describe('Test plot structure', function() {
292292
293293 describe ( 'pie traces' , function ( ) {
294294 var mock = require ( '@mocks/pie_simple.json' ) ;
295+ var gd ;
296+
297+ function countPieTraces ( ) {
298+ return d3 . select ( 'g.pielayer' ) . selectAll ( 'g.trace' ) . size ( ) ;
299+ }
300+
301+ function countBarTraces ( ) {
302+ return d3 . selectAll ( 'g.trace.bars' ) . size ( ) ;
303+ }
295304
296305 beforeEach ( function ( done ) {
297- Plotly . plot ( createGraphDiv ( ) , mock . data , mock . layout ) . then ( done ) ;
306+ gd = createGraphDiv ( ) ;
307+
308+ var mockData = Lib . extendDeep ( [ ] , mock . data ) ,
309+ mockLayout = Lib . extendDeep ( { } , mock . layout ) ;
310+
311+ Plotly . plot ( gd , mockData , mockLayout ) . then ( done ) ;
298312 } ) ;
299313
300314 it ( 'has as many *slice* nodes as there are pie items' , function ( ) {
@@ -319,6 +333,39 @@ describe('Test plot structure', function() {
319333 var testerSVG = d3 . selectAll ( '#js-plotly-tester' ) ;
320334 assertNamespaces ( testerSVG . node ( ) ) ;
321335 } ) ;
336+
337+ it ( 'should be able to get deleted' , function ( done ) {
338+ expect ( countPieTraces ( ) ) . toEqual ( 1 ) ;
339+ expect ( countSubplots ( ) ) . toEqual ( 0 ) ;
340+
341+ Plotly . deleteTraces ( gd , [ 0 ] ) . then ( function ( ) {
342+ expect ( countPieTraces ( ) ) . toEqual ( 0 ) ;
343+ expect ( countSubplots ( ) ) . toEqual ( 0 ) ;
344+
345+ done ( ) ;
346+ } ) ;
347+ } ) ;
348+
349+ it ( 'should be able to be restyled to a bar chart and back' , function ( done ) {
350+ expect ( countPieTraces ( ) ) . toEqual ( 1 ) ;
351+ expect ( countBarTraces ( ) ) . toEqual ( 0 ) ;
352+ expect ( countSubplots ( ) ) . toEqual ( 0 ) ;
353+
354+ Plotly . restyle ( gd , 'type' , 'bar' ) . then ( function ( ) {
355+ expect ( countPieTraces ( ) ) . toEqual ( 0 ) ;
356+ expect ( countBarTraces ( ) ) . toEqual ( 1 ) ;
357+ expect ( countSubplots ( ) ) . toEqual ( 1 ) ;
358+
359+ return Plotly . restyle ( gd , 'type' , 'pie' ) ;
360+ } ) . then ( function ( ) {
361+ expect ( countPieTraces ( ) ) . toEqual ( 1 ) ;
362+ expect ( countBarTraces ( ) ) . toEqual ( 0 ) ;
363+ expect ( countSubplots ( ) ) . toEqual ( 0 ) ;
364+
365+ done ( ) ;
366+ } ) ;
367+
368+ } ) ;
322369 } ) ;
323370 } ) ;
324371
0 commit comments