@@ -62,6 +62,10 @@ describe('Test gl plot interactions', function() {
62
62
mouseEvent ( type , 605 , 271 , opts ) ;
63
63
}
64
64
65
+ function countCanvases ( ) {
66
+ return d3 . selectAll ( 'canvas' ) . size ( ) ;
67
+ }
68
+
65
69
beforeEach ( function ( done ) {
66
70
gd = createGraphDiv ( ) ;
67
71
Plotly . plot ( gd , mock . data , mock . layout ) . then ( function ( ) {
@@ -86,9 +90,6 @@ describe('Test gl plot interactions', function() {
86
90
} ) ;
87
91
88
92
it ( 'should have' , function ( ) {
89
- node = d3 . selectAll ( 'canvas' ) ;
90
- expect ( node [ 0 ] . length ) . toEqual ( 1 , 'one canvas node' ) ;
91
-
92
93
node = d3 . selectAll ( 'g.hovertext' ) ;
93
94
expect ( node . size ( ) ) . toEqual ( 1 , 'one hover text group' ) ;
94
95
@@ -142,6 +143,48 @@ describe('Test gl plot interactions', function() {
142
143
expect ( ptData . pointNumber ) . toEqual ( 2 , 'pointNumber click data' ) ;
143
144
} ) ;
144
145
} ) ;
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
+
145
188
} ) ;
146
189
147
190
describe ( 'gl2d plots' , function ( ) {
0 commit comments