@@ -8216,7 +8216,9 @@ describe('shift tests', function() {
8216
8216
} ) ;
8217
8217
} ) ;
8218
8218
} ) ;
8219
- describe ( 'test tickmode calculator' , function ( ) {
8219
+ fdescribe ( 'test tickmode calculator' , function ( ) {
8220
+ var gd ;
8221
+
8220
8222
beforeEach ( function ( ) {
8221
8223
gd = createGraphDiv ( ) ;
8222
8224
} ) ;
@@ -8229,20 +8231,31 @@ describe('test tickmode calculator', function() {
8229
8231
// Number of ticks will be random
8230
8232
var n = Math . floor ( Math . random ( ) * 99 ) + 1 ;
8231
8233
tickVals = [ ] ;
8232
- for ( let i = 0 ; i <= n ; i ++ ) tickVals . push ( i ) ;
8234
+ for ( let i = 0 ; i <= n ; i ++ ) {
8235
+ tickVals . push ( i ) ;
8236
+ }
8233
8237
standardConfig [ 'tickvals' ] = tickVals ;
8234
8238
standardConfig [ 'ticktext' ] = tickVals ;
8235
8239
return standardConfig ;
8236
8240
}
8237
8241
var ticksOff = { tickmode :"array" , ticks : '' , tickvals :[ ] , ticktext :[ ] , ticklen : 0 , showticklabels : false } ;
8238
- // the goal is target the arrayTicks() function, the subject of PR: https://github.com/plotly/plotly.js/pull/6829
8239
- // we test xMajor and xMinor in on/on on/off off/on and off/off
8240
- // since we can't unit test functions that are not exported, we shim functions we don't care about instead and
8241
- // test the nearest exported functions (calcTicks)
8242
+
8243
+ function _assert ( expLength ) {
8244
+ var ax = gd . _fullLayout . xaxis ;
8245
+
8246
+ // all positions
8247
+ var positions =
8248
+ ax . _vals
8249
+ . filter ( function ( d ) { return d ; } )
8250
+ . map ( function ( d ) { return d . x ; } ) ;
8251
+
8252
+ expect ( positions . length ) . toEqual ( expLength ) ;
8253
+ }
8254
+
8242
8255
describe ( 'arrayTicks' , function ( ) {
8243
8256
for ( let i = 0 ; i < 4 ; i ++ ) {
8244
8257
( function ( i ) {
8245
- it ( 'should return the specified correct number of major ticks and minor ticks' , function ( ) {
8258
+ it ( 'should return the specified correct number of major ticks and minor ticks' , function ( done ) {
8246
8259
const BOTH = 0 ;
8247
8260
const MAJOR = 1 ;
8248
8261
const MINOR = 2 ;
@@ -8259,20 +8272,29 @@ describe('test tickmode calculator', function() {
8259
8272
} else if ( i == NEITHER ) {
8260
8273
// Do nothing, all ticks off
8261
8274
}
8262
- xaxis = {
8263
- r2l : Lib . cleanNumber ,
8264
- d2l : Lib . cleanNumber ,
8265
- _separators : ',' ,
8266
- range : [ 0 , 1000 ] ,
8267
- ...xMajorConfig ,
8268
- minor : {
8269
- ...xMinorConfig ,
8270
- } ,
8271
- } ;
8272
- Axes . prepMinorTicks = function ( ) { return } ; // Not part of this test
8273
- Axes . prepTicks = function ( ) { return } ; // Not part of this test
8274
- ticksOut = Axes . calcTicks ( xaxis ) ;
8275
- expect ( ticksOut . length ) . toEqual ( xMajorConfig . tickvals . length + xMinorConfig . tickvals . length ) ;
8275
+ Plotly . newPlot ( gd , {
8276
+ data : [ {
8277
+ x : [ 0 , 1 ] ,
8278
+ y : [ 0 , 1 ]
8279
+ } ] ,
8280
+ layout : {
8281
+ width : 400 ,
8282
+ height : 400 ,
8283
+ margin : {
8284
+ t : 40 ,
8285
+ b : 40 ,
8286
+ l : 40 ,
8287
+ r : 40
8288
+ } ,
8289
+ xaxis : {
8290
+ range : [ 0 , 1000 ] ,
8291
+ ...xMajorConfig ,
8292
+ minor : xMinorConfig ,
8293
+ } ,
8294
+ }
8295
+ } ) . then ( function ( ) {
8296
+ _assert ( xMajorConfig . tickvals . length + xMinorConfig . tickvals . length ) ;
8297
+ } ) . then ( done , done . fail ) ;
8276
8298
} ) ;
8277
8299
} ) ( i ) ;
8278
8300
}
0 commit comments