1- var Plotly = require ( '@src/plotly' ) ;
1+ var PlotlyInternal = require ( '@src/plotly' ) ;
2+
3+ var Plots = require ( '@src/plots/plots' ) ;
4+ var Lib = require ( '@src/lib' ) ;
5+ var Color = require ( '@src/components/color' ) ;
6+
7+ var handleTickValueDefaults = require ( '@src/plots/cartesian/tick_value_defaults' ) ;
8+ var Axes = PlotlyInternal . Axes ;
29
310
411describe ( 'Test axes' , function ( ) {
@@ -28,15 +35,15 @@ describe('Test axes', function() {
2835 }
2936 }
3037 } ;
31- var expectedYaxis = Plotly . Lib . extendDeep ( { } , gd . layout . xaxis ) ,
38+ var expectedYaxis = Lib . extendDeep ( { } , gd . layout . xaxis ) ,
3239 expectedXaxis = {
3340 title : 'Click to enter X axis title' ,
3441 type : 'date'
3542 } ;
3643
37- Plotly . Plots . supplyDefaults ( gd ) ;
44+ Plots . supplyDefaults ( gd ) ;
3845
39- Plotly . Axes . swap ( gd , [ 0 ] ) ;
46+ Axes . swap ( gd , [ 0 ] ) ;
4047
4148 expect ( gd . layout . xaxis ) . toEqual ( expectedXaxis ) ;
4249 expect ( gd . layout . yaxis ) . toEqual ( expectedYaxis ) ;
@@ -61,13 +68,13 @@ describe('Test axes', function() {
6168 }
6269 }
6370 } ;
64- var expectedLayoutAfter = Plotly . Lib . extendDeep ( { } , gd . layout ) ;
71+ var expectedLayoutAfter = Lib . extendDeep ( { } , gd . layout ) ;
6572 expectedLayoutAfter . xaxis . type = 'linear' ;
6673 expectedLayoutAfter . yaxis . type = 'linear' ;
6774
68- Plotly . Plots . supplyDefaults ( gd ) ;
75+ Plots . supplyDefaults ( gd ) ;
6976
70- Plotly . Axes . swap ( gd , [ 0 ] ) ;
77+ Axes . swap ( gd , [ 0 ] ) ;
7178
7279 expect ( gd . layout . xaxis ) . toEqual ( expectedLayoutAfter . xaxis ) ;
7380 expect ( gd . layout . yaxis ) . toEqual ( expectedLayoutAfter . yaxis ) ;
@@ -145,9 +152,9 @@ describe('Test axes', function() {
145152 { x : 5 , y : 0.5 , xref : 'x' , yref : 'paper' }
146153 ] ;
147154
148- Plotly . Plots . supplyDefaults ( gd ) ;
155+ Plots . supplyDefaults ( gd ) ;
149156
150- Plotly . Axes . swap ( gd , [ 0 , 1 ] ) ;
157+ Axes . swap ( gd , [ 0 , 1 ] ) ;
151158
152159 expect ( gd . layout . xaxis ) . toEqual ( expectedXaxis ) ;
153160 expect ( gd . layout . xaxis2 ) . toEqual ( expectedXaxis2 ) ;
@@ -161,7 +168,7 @@ describe('Test axes', function() {
161168 layoutOut = { } ,
162169 fullData = [ ] ;
163170
164- var supplyLayoutDefaults = Plotly . Axes . supplyLayoutDefaults ;
171+ var supplyLayoutDefaults = Axes . supplyLayoutDefaults ;
165172
166173 it ( 'should set undefined linewidth/linecolor if linewidth, linecolor or showline is not supplied' , function ( ) {
167174 layoutIn = {
@@ -181,7 +188,7 @@ describe('Test axes', function() {
181188 } ;
182189 supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
183190 expect ( layoutOut . xaxis . linewidth ) . toBe ( 1 ) ;
184- expect ( layoutOut . xaxis . linecolor ) . toBe ( Plotly . Color . defaultLine ) ;
191+ expect ( layoutOut . xaxis . linecolor ) . toBe ( Color . defaultLine ) ;
185192 } ) ;
186193
187194 it ( 'should set linewidth to default if linecolor is supplied and valid' , function ( ) {
@@ -199,7 +206,7 @@ describe('Test axes', function() {
199206 } ;
200207 supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
201208 expect ( layoutOut . yaxis . linewidth ) . toBe ( 2 ) ;
202- expect ( layoutOut . yaxis . linecolor ) . toBe ( Plotly . Color . defaultLine ) ;
209+ expect ( layoutOut . yaxis . linecolor ) . toBe ( Color . defaultLine ) ;
203210 } ) ;
204211
205212 it ( 'should set default gridwidth and gridcolor' , function ( ) {
@@ -209,9 +216,9 @@ describe('Test axes', function() {
209216 } ;
210217 supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
211218 expect ( layoutOut . xaxis . gridwidth ) . toBe ( 1 ) ;
212- expect ( layoutOut . xaxis . gridcolor ) . toBe ( Plotly . Color . lightLine ) ;
219+ expect ( layoutOut . xaxis . gridcolor ) . toBe ( Color . lightLine ) ;
213220 expect ( layoutOut . yaxis . gridwidth ) . toBe ( 1 ) ;
214- expect ( layoutOut . yaxis . gridcolor ) . toBe ( Plotly . Color . lightLine ) ;
221+ expect ( layoutOut . yaxis . gridcolor ) . toBe ( Color . lightLine ) ;
215222 } ) ;
216223
217224 it ( 'should set gridcolor/gridwidth to undefined if showgrid is false' , function ( ) {
@@ -230,9 +237,9 @@ describe('Test axes', function() {
230237 } ;
231238 supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
232239 expect ( layoutOut . xaxis . zerolinewidth ) . toBe ( 1 ) ;
233- expect ( layoutOut . xaxis . zerolinecolor ) . toBe ( Plotly . Color . defaultLine ) ;
240+ expect ( layoutOut . xaxis . zerolinecolor ) . toBe ( Color . defaultLine ) ;
234241 expect ( layoutOut . yaxis . zerolinewidth ) . toBe ( 1 ) ;
235- expect ( layoutOut . yaxis . zerolinecolor ) . toBe ( Plotly . Color . defaultLine ) ;
242+ expect ( layoutOut . yaxis . zerolinecolor ) . toBe ( Color . defaultLine ) ;
236243 } ) ;
237244
238245 it ( 'should set zerolinecolor/zerolinewidth to undefined if zeroline is false' , function ( ) {
@@ -246,103 +253,101 @@ describe('Test axes', function() {
246253 } ) ;
247254
248255 describe ( 'handleTickValueDefaults' , function ( ) {
249- function handleTickValueDefaults ( axIn , axOut , axType ) {
256+ function mockSupplyDefaults ( axIn , axOut , axType ) {
250257 function coerce ( attr , dflt ) {
251- return Plotly . Lib . coerce ( axIn , axOut ,
252- Plotly . Axes . layoutAttributes ,
253- attr , dflt ) ;
258+ return Lib . coerce ( axIn , axOut , Axes . layoutAttributes , attr , dflt ) ;
254259 }
255260
256- Plotly . Axes . handleTickValueDefaults ( axIn , axOut , coerce , axType ) ;
261+ handleTickValueDefaults ( axIn , axOut , coerce , axType ) ;
257262 }
258263
259264 it ( 'should set default tickmode correctly' , function ( ) {
260265 var axIn = { } ,
261266 axOut = { } ;
262- handleTickValueDefaults ( axIn , axOut , 'linear' ) ;
267+ mockSupplyDefaults ( axIn , axOut , 'linear' ) ;
263268 expect ( axOut . tickmode ) . toBe ( 'auto' ) ;
264269
265270 axIn = { tickmode : 'array' , tickvals : 'stuff' } ;
266271 axOut = { } ;
267- handleTickValueDefaults ( axIn , axOut , 'linear' ) ;
272+ mockSupplyDefaults ( axIn , axOut , 'linear' ) ;
268273 expect ( axOut . tickmode ) . toBe ( 'auto' ) ;
269274
270275 axIn = { tickmode : 'array' , tickvals : [ 1 , 2 , 3 ] } ;
271276 axOut = { } ;
272- handleTickValueDefaults ( axIn , axOut , 'date' ) ;
277+ mockSupplyDefaults ( axIn , axOut , 'date' ) ;
273278 expect ( axOut . tickmode ) . toBe ( 'auto' ) ;
274279
275280 axIn = { tickvals : [ 1 , 2 , 3 ] } ;
276281 axOut = { } ;
277- handleTickValueDefaults ( axIn , axOut , 'linear' ) ;
282+ mockSupplyDefaults ( axIn , axOut , 'linear' ) ;
278283 expect ( axOut . tickmode ) . toBe ( 'array' ) ;
279284
280285 axIn = { dtick : 1 } ;
281286 axOut = { } ;
282- handleTickValueDefaults ( axIn , axOut , 'linear' ) ;
287+ mockSupplyDefaults ( axIn , axOut , 'linear' ) ;
283288 expect ( axOut . tickmode ) . toBe ( 'linear' ) ;
284289 } ) ;
285290
286291 it ( 'should set nticks iff tickmode=auto' , function ( ) {
287292 var axIn = { } ,
288293 axOut = { } ;
289- handleTickValueDefaults ( axIn , axOut , 'linear' ) ;
294+ mockSupplyDefaults ( axIn , axOut , 'linear' ) ;
290295 expect ( axOut . nticks ) . toBe ( 0 ) ;
291296
292297 axIn = { tickmode : 'auto' , nticks : 5 } ;
293298 axOut = { } ;
294- handleTickValueDefaults ( axIn , axOut , 'linear' ) ;
299+ mockSupplyDefaults ( axIn , axOut , 'linear' ) ;
295300 expect ( axOut . nticks ) . toBe ( 5 ) ;
296301
297302 axIn = { tickmode : 'linear' , nticks : 15 } ;
298303 axOut = { } ;
299- handleTickValueDefaults ( axIn , axOut , 'linear' ) ;
304+ mockSupplyDefaults ( axIn , axOut , 'linear' ) ;
300305 expect ( axOut . nticks ) . toBe ( undefined ) ;
301306 } ) ;
302307
303308 it ( 'should set tick0 and dtick iff tickmode=linear' , function ( ) {
304309 var axIn = { tickmode : 'auto' , tick0 : 1 , dtick : 1 } ,
305310 axOut = { } ;
306- handleTickValueDefaults ( axIn , axOut , 'linear' ) ;
311+ mockSupplyDefaults ( axIn , axOut , 'linear' ) ;
307312 expect ( axOut . tick0 ) . toBe ( undefined ) ;
308313 expect ( axOut . dtick ) . toBe ( undefined ) ;
309314
310315 axIn = { tickvals : [ 1 , 2 , 3 ] , tick0 : 1 , dtick : 1 } ;
311316 axOut = { } ;
312- handleTickValueDefaults ( axIn , axOut , 'linear' ) ;
317+ mockSupplyDefaults ( axIn , axOut , 'linear' ) ;
313318 expect ( axOut . tick0 ) . toBe ( undefined ) ;
314319 expect ( axOut . dtick ) . toBe ( undefined ) ;
315320
316321 axIn = { tick0 : 2.71 , dtick : 0.00828 } ;
317322 axOut = { } ;
318- handleTickValueDefaults ( axIn , axOut , 'linear' ) ;
323+ mockSupplyDefaults ( axIn , axOut , 'linear' ) ;
319324 expect ( axOut . tick0 ) . toBe ( 2.71 ) ;
320325 expect ( axOut . dtick ) . toBe ( 0.00828 ) ;
321326
322327 axIn = { tickmode : 'linear' , tick0 : 3.14 , dtick : 0.00159 } ;
323328 axOut = { } ;
324- handleTickValueDefaults ( axIn , axOut , 'linear' ) ;
329+ mockSupplyDefaults ( axIn , axOut , 'linear' ) ;
325330 expect ( axOut . tick0 ) . toBe ( 3.14 ) ;
326331 expect ( axOut . dtick ) . toBe ( 0.00159 ) ;
327332 } ) ;
328333
329334 it ( 'should set tickvals and ticktext iff tickmode=array' , function ( ) {
330335 var axIn = { tickmode : 'auto' , tickvals : [ 1 , 2 , 3 ] , ticktext : [ '4' , '5' , '6' ] } ,
331336 axOut = { } ;
332- handleTickValueDefaults ( axIn , axOut , 'linear' ) ;
337+ mockSupplyDefaults ( axIn , axOut , 'linear' ) ;
333338 expect ( axOut . tickvals ) . toBe ( undefined ) ;
334339 expect ( axOut . ticktext ) . toBe ( undefined ) ;
335340
336341 axIn = { tickvals : [ 2 , 4 , 6 , 8 ] , ticktext : [ 'who' , 'do' , 'we' , 'appreciate' ] } ;
337342 axOut = { } ;
338- handleTickValueDefaults ( axIn , axOut , 'linear' ) ;
343+ mockSupplyDefaults ( axIn , axOut , 'linear' ) ;
339344 expect ( axOut . tickvals ) . toEqual ( [ 2 , 4 , 6 , 8 ] ) ;
340345 expect ( axOut . ticktext ) . toEqual ( [ 'who' , 'do' , 'we' , 'appreciate' ] ) ;
341346 } ) ;
342347 } ) ;
343348
344349 describe ( 'saveRangeInitial' , function ( ) {
345- var saveRangeInitial = Plotly . Axes . saveRangeInitial ;
350+ var saveRangeInitial = Axes . saveRangeInitial ;
346351 var gd , hasOneAxisChanged ;
347352
348353 beforeEach ( function ( ) {
@@ -401,7 +406,7 @@ describe('Test axes', function() {
401406 } ) ;
402407
403408 describe ( 'list' , function ( ) {
404- var listFunc = Plotly . Axes . list ;
409+ var listFunc = Axes . list ;
405410 var gd ;
406411
407412 it ( 'returns empty array when no fullLayout is present' , function ( ) {
@@ -484,7 +489,7 @@ describe('Test axes', function() {
484489 } ) ;
485490
486491 describe ( 'getSubplots' , function ( ) {
487- var getSubplots = Plotly . Axes . getSubplots ;
492+ var getSubplots = Axes . getSubplots ;
488493 var gd ;
489494
490495 it ( 'returns list of subplots ids (from data only)' , function ( ) {
0 commit comments