1
1
var Gl3d = require ( '@src/plots/gl3d' ) ;
2
- var Plots = require ( '@src/plots/plots' ) ;
3
2
4
3
var tinycolor = require ( 'tinycolor2' ) ;
5
4
var Color = require ( '@src/components/color' ) ;
@@ -14,9 +13,7 @@ describe('Test Gl3d layout defaults', function() {
14
13
var supplyLayoutDefaults = Gl3d . supplyLayoutDefaults ;
15
14
16
15
beforeEach ( function ( ) {
17
- layoutOut = {
18
- _has : Plots . _hasPlotType
19
- } ;
16
+ layoutOut = { _basePlotModules : [ 'gl3d' ] } ;
20
17
21
18
// needs a scene-ref in a trace in order to be detected
22
19
fullData = [ { type : 'scatter3d' , scene : 'scene' } ] ;
@@ -174,8 +171,13 @@ describe('Test Gl3d layout defaults', function() {
174
171
expect ( layoutOut . scene . dragmode )
175
172
. toBe ( 'orbit' , 'to user layout val if valid and 3d only' ) ;
176
173
174
+ layoutIn = { scene : { } , dragmode : 'invalid' } ;
175
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
176
+ expect ( layoutOut . scene . dragmode )
177
+ . toBe ( 'turntable' , 'to turntable if invalid and 3d only' ) ;
178
+
177
179
layoutIn = { scene : { } , dragmode : 'orbit' } ;
178
- layoutOut . _basePlotModules = [ { name : 'cartesian' } ] ;
180
+ layoutOut . _basePlotModules . push ( { name : 'cartesian' } ) ;
179
181
supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
180
182
expect ( layoutOut . scene . dragmode )
181
183
. toBe ( 'turntable' , 'to default if not 3d only' ) ;
@@ -202,8 +204,13 @@ describe('Test Gl3d layout defaults', function() {
202
204
expect ( layoutOut . scene . hovermode )
203
205
. toBe ( false , 'to user layout val if valid and 3d only' ) ;
204
206
207
+ layoutIn = { scene : { } , hovermode : 'invalid' } ;
208
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
209
+ expect ( layoutOut . scene . hovermode )
210
+ . toBe ( 'closest' , 'to closest if invalid and 3d only' ) ;
211
+
205
212
layoutIn = { scene : { } , hovermode : false } ;
206
- layoutOut . _basePlotModules = [ { name : 'cartesian' } ] ;
213
+ layoutOut . _basePlotModules . push ( { name : 'cartesian' } ) ;
207
214
supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
208
215
expect ( layoutOut . scene . hovermode )
209
216
. toBe ( 'closest' , 'to default if not 3d only' ) ;
0 commit comments