1
1
var Gl3d = require ( '@src/plots/gl3d' ) ;
2
2
3
3
4
- describe ( 'Test Gl3d layout defaults' , function ( ) {
4
+ fdescribe ( 'Test Gl3d layout defaults' , function ( ) {
5
5
'use strict' ;
6
6
7
7
describe ( 'supplyLayoutDefaults' , function ( ) {
8
- var layoutIn ,
9
- layoutOut ;
10
-
11
8
var supplyLayoutDefaults = Gl3d . supplyLayoutDefaults ;
9
+ var layoutIn , layoutOut , fullData ;
12
10
13
11
beforeEach ( function ( ) {
14
- layoutOut = {
15
- _hasGL3D : true
16
- } ;
12
+ layoutOut = { _hasGL3D : true } ;
13
+ fullData = [ { scene : 'scene' , type : 'scatter3d' } ] ;
17
14
} ) ;
18
15
19
16
it ( 'should coerce aspectmode=ratio when ratio data is valid' , function ( ) {
@@ -39,7 +36,7 @@ describe('Test Gl3d layout defaults', function() {
39
36
}
40
37
} ;
41
38
42
- supplyLayoutDefaults ( layoutIn , layoutOut , [ { scene : 'scene' , type : 'scatter3d' } ] ) ;
39
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
43
40
expect ( layoutOut . scene . aspectmode ) . toBe ( expected . scene . aspectmode ) ;
44
41
expect ( layoutOut . scene . aspectratio ) . toEqual ( expected . scene . aspectratio ) ;
45
42
expect ( layoutOut . scene . bgcolor ) . toBe ( expected . scene . bgcolor ) ;
@@ -68,7 +65,7 @@ describe('Test Gl3d layout defaults', function() {
68
65
}
69
66
} ;
70
67
71
- supplyLayoutDefaults ( layoutIn , layoutOut , [ { scene : 'scene' , type : 'scatter3d' } ] ) ;
68
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
72
69
expect ( layoutOut . scene . aspectmode ) . toBe ( expected . scene . aspectmode ) ;
73
70
expect ( layoutOut . scene . aspectratio ) . toEqual ( expected . scene . aspectratio ) ;
74
71
} ) ;
@@ -96,7 +93,7 @@ describe('Test Gl3d layout defaults', function() {
96
93
}
97
94
} ;
98
95
99
- supplyLayoutDefaults ( layoutIn , layoutOut , [ { scene : 'scene' , type : 'scatter3d' } ] ) ;
96
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
100
97
expect ( layoutOut . scene . aspectmode ) . toBe ( expected . scene . aspectmode ) ;
101
98
expect ( layoutOut . scene . aspectratio ) . toEqual ( expected . scene . aspectratio ) ;
102
99
} ) ;
@@ -124,7 +121,7 @@ describe('Test Gl3d layout defaults', function() {
124
121
}
125
122
} ;
126
123
127
- supplyLayoutDefaults ( layoutIn , layoutOut , [ { scene : 'scene' , type : 'scatter3d' } ] ) ;
124
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
128
125
expect ( layoutOut . scene . aspectmode ) . toBe ( expected . scene . aspectmode ) ;
129
126
expect ( layoutOut . scene . aspectratio ) . toEqual ( expected . scene . aspectratio ) ;
130
127
} ) ;
@@ -152,12 +149,65 @@ describe('Test Gl3d layout defaults', function() {
152
149
}
153
150
} ;
154
151
155
- supplyLayoutDefaults ( layoutIn , layoutOut , [ { scene : 'scene' , type : 'scatter3d' } ] ) ;
152
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
156
153
expect ( layoutOut . scene . aspectmode ) . toBe ( expected . scene . aspectmode ) ;
157
154
expect ( layoutOut . scene . aspectratio ) . toEqual ( expected . scene . aspectratio ) ;
158
155
} ) ;
159
156
157
+ it ( 'should coerce dragmode' , function ( ) {
158
+ layoutIn = { } ;
159
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
160
+ expect ( layoutOut . scene . dragmode )
161
+ . toBe ( 'turntable' , 'to turntable by default' ) ;
162
+
163
+ layoutIn = { scene : { dragmode : 'orbit' } } ;
164
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
165
+ expect ( layoutOut . scene . dragmode )
166
+ . toBe ( 'orbit' , 'to user val if valid' ) ;
167
+
168
+ layoutIn = { dragmode : 'orbit' } ;
169
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
170
+ expect ( layoutOut . scene . dragmode )
171
+ . toBe ( 'orbit' , 'to user layout val if valid and 3d only' ) ;
172
+
173
+ layoutIn = { dragmode : 'orbit' } ;
174
+ layoutOut . _hasCartesian = true ;
175
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
176
+ expect ( layoutOut . scene . dragmode )
177
+ . toBe ( 'turntable' , 'to default if not 3d only' ) ;
178
+
179
+ layoutIn = { dragmode : 'not gonna work' } ;
180
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
181
+ expect ( layoutOut . scene . dragmode )
182
+ . toBe ( 'turntable' , 'to default if not valid' ) ;
183
+ } ) ;
160
184
161
-
185
+ it ( 'should coerce hovermode' , function ( ) {
186
+ layoutIn = { } ;
187
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
188
+ expect ( layoutOut . scene . hovermode )
189
+ . toBe ( 'closest' , 'to closest by default' ) ;
190
+
191
+ layoutIn = { scene : { hovermode : false } } ;
192
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
193
+ expect ( layoutOut . scene . hovermode )
194
+ . toBe ( false , 'to user val if valid' ) ;
195
+
196
+ layoutIn = { hovermode : false } ;
197
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
198
+ expect ( layoutOut . scene . hovermode )
199
+ . toBe ( false , 'to user layout val if valid and 3d only' ) ;
200
+
201
+ layoutIn = { hovermode : false } ;
202
+ layoutOut . _hasCartesian = true ;
203
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
204
+ expect ( layoutOut . scene . hovermode )
205
+ . toBe ( 'closest' , 'to default if not 3d only' ) ;
206
+
207
+ layoutIn = { hovermode : 'not gonna work' } ;
208
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
209
+ expect ( layoutOut . scene . hovermode )
210
+ . toBe ( 'closest' , 'to default if not valid' ) ;
211
+ } ) ;
162
212
} ) ;
163
213
} ) ;
0 commit comments