@@ -62,6 +62,10 @@ describe('Test gl plot interactions', function() {
6262 mouseEvent ( type , 605 , 271 , opts ) ;
6363 }
6464
65+ function countCanvases ( ) {
66+ return d3 . selectAll ( 'canvas' ) . size ( ) ;
67+ }
68+
6569 beforeEach ( function ( done ) {
6670 gd = createGraphDiv ( ) ;
6771 Plotly . plot ( gd , mock . data , mock . layout ) . then ( function ( ) {
@@ -86,9 +90,6 @@ describe('Test gl plot interactions', function() {
8690 } ) ;
8791
8892 it ( 'should have' , function ( ) {
89- node = d3 . selectAll ( 'canvas' ) ;
90- expect ( node [ 0 ] . length ) . toEqual ( 1 , 'one canvas node' ) ;
91-
9293 node = d3 . selectAll ( 'g.hovertext' ) ;
9394 expect ( node . size ( ) ) . toEqual ( 1 , 'one hover text group' ) ;
9495
@@ -142,6 +143,48 @@ describe('Test gl plot interactions', function() {
142143 expect ( ptData . pointNumber ) . toEqual ( 2 , 'pointNumber click data' ) ;
143144 } ) ;
144145 } ) ;
146+
147+ it ( 'should be able to reversibly change trace type' , function ( done ) {
148+ var sceneLayout = { aspectratio : { x : 1 , y : 1 , z : 1 } } ;
149+
150+ expect ( countCanvases ( ) ) . toEqual ( 1 ) ;
151+ expect ( gd . layout . scene ) . toEqual ( sceneLayout ) ;
152+ expect ( gd . layout . xaxis ) . toBeUndefined ( ) ;
153+ expect ( gd . layout . yaxis ) . toBeUndefined ( ) ;
154+ expect ( gd . _fullLayout . _hasGL3D ) . toBe ( true ) ;
155+ expect ( gd . _fullLayout . scene . _scene ) . toBeDefined ( ) ;
156+
157+ Plotly . restyle ( gd , 'type' , 'scatter' ) . then ( function ( ) {
158+ expect ( countCanvases ( ) ) . toEqual ( 0 ) ;
159+ expect ( gd . layout . scene ) . toEqual ( sceneLayout ) ;
160+ expect ( gd . layout . xaxis ) . toBeDefined ( ) ;
161+ expect ( gd . layout . yaxis ) . toBeDefined ( ) ;
162+ expect ( gd . _fullLayout . _hasGL3D ) . toBe ( false ) ;
163+ expect ( gd . _fullLayout . scene ) . toBeUndefined ( ) ;
164+
165+ return Plotly . restyle ( gd , 'type' , 'scatter3d' ) ;
166+ } ) . then ( function ( ) {
167+ expect ( countCanvases ( ) ) . toEqual ( 1 ) ;
168+ expect ( gd . layout . scene ) . toEqual ( sceneLayout ) ;
169+ expect ( gd . layout . xaxis ) . toBeDefined ( ) ;
170+ expect ( gd . layout . yaxis ) . toBeDefined ( ) ;
171+ expect ( gd . _fullLayout . _hasGL3D ) . toBe ( true ) ;
172+ expect ( gd . _fullLayout . scene . _scene ) . toBeDefined ( ) ;
173+
174+ done ( ) ;
175+ } ) ;
176+ } ) ;
177+
178+ it ( 'should be able to delete the last trace' , function ( done ) {
179+ Plotly . deleteTraces ( gd , [ 0 ] ) . then ( function ( ) {
180+ expect ( countCanvases ( ) ) . toEqual ( 0 ) ;
181+ expect ( gd . _fullLayout . _hasGL3D ) . toBe ( false ) ;
182+ expect ( gd . _fullLayout . scene ) . toBeUndefined ( ) ;
183+
184+ done ( ) ;
185+ } ) ;
186+ } ) ;
187+
145188 } ) ;
146189
147190 describe ( 'gl2d plots' , function ( ) {
0 commit comments