@@ -1264,11 +1264,11 @@ describe('Test axes', function() {
12641264 // way of getting a new clean copy each time.
12651265 function getDefaultAx ( ) {
12661266 return {
1267+ autorange : true ,
12671268 c2l : Number ,
12681269 type : 'linear' ,
12691270 _length : 100 ,
1270- _m : 1 ,
1271- _needsExpand : true
1271+ _m : 1
12721272 } ;
12731273 }
12741274
@@ -1284,15 +1284,14 @@ describe('Test axes', function() {
12841284
12851285 it ( 'calls ax.setScale if necessary' , function ( ) {
12861286 ax = {
1287+ autorange : true ,
12871288 c2l : Number ,
12881289 type : 'linear' ,
1289- setScale : function ( ) { } ,
1290- _needsExpand : true
1290+ setScale : function ( ) { }
12911291 } ;
12921292 spyOn ( ax , 'setScale' ) ;
1293- data = [ 1 ] ;
12941293
1295- expand ( ax , data ) ;
1294+ expand ( ax , [ 1 ] ) ;
12961295
12971296 expect ( ax . setScale ) . toHaveBeenCalled ( ) ;
12981297 } ) ;
@@ -1450,6 +1449,38 @@ describe('Test axes', function() {
14501449 expect ( ax . _min ) . toEqual ( [ { val : 0 , pad : 0 } ] ) ;
14511450 expect ( ax . _max ) . toEqual ( [ { val : 6 , pad : 15 } ] ) ;
14521451 } ) ;
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+ } ) ;
14531484 } ) ;
14541485
14551486 describe ( 'calcTicks and tickText' , function ( ) {
0 commit comments