@@ -155,6 +155,95 @@ describe('Test axes', function () {
155
155
} ) ;
156
156
} ) ;
157
157
158
+ describe ( 'supplyLayoutDefaults' , function ( ) {
159
+ var layoutIn = { } ,
160
+ layoutOut = { } ,
161
+ fullData = [ ] ;
162
+
163
+ var supplyLayoutDefaults = Plotly . Axes . supplyLayoutDefaults ;
164
+
165
+ it ( 'should set undefined linewidth/linecolor if linewidth, linecolor or showline is not supplied' , function ( ) {
166
+ layoutIn = {
167
+ xaxis : { } ,
168
+ yaxis : { }
169
+ } ;
170
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
171
+ expect ( layoutOut . xaxis . linewidth ) . toBe ( undefined ) ;
172
+ expect ( layoutOut . xaxis . linecolor ) . toBe ( undefined ) ;
173
+ expect ( layoutOut . yaxis . linewidth ) . toBe ( undefined ) ;
174
+ expect ( layoutOut . yaxis . linecolor ) . toBe ( undefined ) ;
175
+ } ) ;
176
+
177
+ it ( 'should set default linewidth and linecolor if showline is true' , function ( ) {
178
+ layoutIn = {
179
+ xaxis : { showline : true }
180
+ } ;
181
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
182
+ expect ( layoutOut . xaxis . linewidth ) . toBe ( 1 ) ;
183
+ expect ( layoutOut . xaxis . linecolor ) . toBe ( Plotly . Color . defaultLine ) ;
184
+ } ) ;
185
+
186
+ it ( 'should set linewidth to default if linecolor is supplied and valid' , function ( ) {
187
+ layoutIn = {
188
+ xaxis : { linecolor :'black' }
189
+ } ;
190
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
191
+ expect ( layoutOut . xaxis . linecolor ) . toBe ( 'black' ) ;
192
+ expect ( layoutOut . xaxis . linewidth ) . toBe ( 1 ) ;
193
+ } ) ;
194
+
195
+ it ( 'should set linecolor to default if linewidth is supplied and valid' , function ( ) {
196
+ layoutIn = {
197
+ yaxis : { linewidth :2 }
198
+ } ;
199
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
200
+ expect ( layoutOut . yaxis . linewidth ) . toBe ( 2 ) ;
201
+ expect ( layoutOut . yaxis . linecolor ) . toBe ( Plotly . Color . defaultLine ) ;
202
+ } ) ;
203
+
204
+ it ( 'should set default gridwidth and gridcolor' , function ( ) {
205
+ layoutIn = {
206
+ xaxis : { } ,
207
+ yaxis : { }
208
+ } ;
209
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
210
+ expect ( layoutOut . xaxis . gridwidth ) . toBe ( 1 ) ;
211
+ expect ( layoutOut . xaxis . gridcolor ) . toBe ( Plotly . Color . lightLine ) ;
212
+ expect ( layoutOut . yaxis . gridwidth ) . toBe ( 1 ) ;
213
+ expect ( layoutOut . yaxis . gridcolor ) . toBe ( Plotly . Color . lightLine ) ;
214
+ } ) ;
215
+
216
+ it ( 'should set gridcolor/gridwidth to undefined if showgrid is false' , function ( ) {
217
+ layoutIn = {
218
+ yaxis : { showgrid : false }
219
+ } ;
220
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
221
+ expect ( layoutOut . yaxis . gridwidth ) . toBe ( undefined ) ;
222
+ expect ( layoutOut . yaxis . gridcolor ) . toBe ( undefined ) ;
223
+ } ) ;
224
+
225
+ it ( 'should set default zerolinecolor/zerolinewidth' , function ( ) {
226
+ layoutIn = {
227
+ xaxis : { } ,
228
+ yaxis : { }
229
+ } ;
230
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
231
+ expect ( layoutOut . xaxis . zerolinewidth ) . toBe ( 1 ) ;
232
+ expect ( layoutOut . xaxis . zerolinecolor ) . toBe ( Plotly . Color . defaultLine ) ;
233
+ expect ( layoutOut . yaxis . zerolinewidth ) . toBe ( 1 ) ;
234
+ expect ( layoutOut . yaxis . zerolinecolor ) . toBe ( Plotly . Color . defaultLine ) ;
235
+ } ) ;
236
+
237
+ it ( 'should set zerolinecolor/zerolinewidth to undefined if zeroline is false' , function ( ) {
238
+ layoutIn = {
239
+ xaxis : { zeroline : false }
240
+ } ;
241
+ supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
242
+ expect ( layoutOut . xaxis . zerolinewidth ) . toBe ( undefined ) ;
243
+ expect ( layoutOut . xaxis . zerolinecolor ) . toBe ( undefined ) ;
244
+ } ) ;
245
+ } ) ;
246
+
158
247
describe ( 'handleTickValueDefaults' , function ( ) {
159
248
function handleTickValueDefaults ( axIn , axOut , axType ) {
160
249
function coerce ( attr , dflt ) {
0 commit comments