@@ -1264,11 +1264,11 @@ describe('Test axes', function() {
1264
1264
// way of getting a new clean copy each time.
1265
1265
function getDefaultAx ( ) {
1266
1266
return {
1267
+ autorange : true ,
1267
1268
c2l : Number ,
1268
1269
type : 'linear' ,
1269
1270
_length : 100 ,
1270
- _m : 1 ,
1271
- _needsExpand : true
1271
+ _m : 1
1272
1272
} ;
1273
1273
}
1274
1274
@@ -1284,15 +1284,14 @@ describe('Test axes', function() {
1284
1284
1285
1285
it ( 'calls ax.setScale if necessary' , function ( ) {
1286
1286
ax = {
1287
+ autorange : true ,
1287
1288
c2l : Number ,
1288
1289
type : 'linear' ,
1289
- setScale : function ( ) { } ,
1290
- _needsExpand : true
1290
+ setScale : function ( ) { }
1291
1291
} ;
1292
1292
spyOn ( ax , 'setScale' ) ;
1293
- data = [ 1 ] ;
1294
1293
1295
- expand ( ax , data ) ;
1294
+ expand ( ax , [ 1 ] ) ;
1296
1295
1297
1296
expect ( ax . setScale ) . toHaveBeenCalled ( ) ;
1298
1297
} ) ;
@@ -1450,6 +1449,38 @@ describe('Test axes', function() {
1450
1449
expect ( ax . _min ) . toEqual ( [ { val : 0 , pad : 0 } ] ) ;
1451
1450
expect ( ax . _max ) . toEqual ( [ { val : 6 , pad : 15 } ] ) ;
1452
1451
} ) ;
1452
+
1453
+ it ( 'should return early if no data is given' , function ( ) {
1454
+ ax = getDefaultAx ( ) ;
1455
+
1456
+ expand ( ax ) ;
1457
+ expect ( ax . _min ) . toBeUndefined ( ) ;
1458
+ expect ( ax . _max ) . toBeUndefined ( ) ;
1459
+ } ) ;
1460
+
1461
+ it ( 'should return early if `autorange` is falsy' , function ( ) {
1462
+ ax = getDefaultAx ( ) ;
1463
+ data = [ 2 , 5 ] ;
1464
+
1465
+ ax . autorange = false ;
1466
+ ax . rangeslider = { autorange : false } ;
1467
+
1468
+ expand ( ax , data , { } ) ;
1469
+ expect ( ax . _min ) . toBeUndefined ( ) ;
1470
+ expect ( ax . _max ) . toBeUndefined ( ) ;
1471
+ } ) ;
1472
+
1473
+ it ( 'should consider range slider `autorange`' , function ( ) {
1474
+ ax = getDefaultAx ( ) ;
1475
+ data = [ 2 , 5 ] ;
1476
+
1477
+ ax . autorange = false ;
1478
+ ax . rangeslider = { autorange : true } ;
1479
+
1480
+ expand ( ax , data , { } ) ;
1481
+ expect ( ax . _min ) . toEqual ( [ { val : 2 , pad : 0 } ] ) ;
1482
+ expect ( ax . _max ) . toEqual ( [ { val : 5 , pad : 0 } ] ) ;
1483
+ } ) ;
1453
1484
} ) ;
1454
1485
1455
1486
describe ( 'calcTicks and tickText' , function ( ) {
0 commit comments