@@ -2226,6 +2226,29 @@ describe('Test axes', function() {
22262226 expect ( ax . _categories ) . toEqual ( [ 'a' , 'b' , 'c' , 'd' ] ) ;
22272227 } ) ;
22282228
2229+ it ( 'notices when all categories are off the edge' , function ( ) {
2230+ var ax = {
2231+ type : 'category' ,
2232+ _categories : [ 'a' , 'b' , 'c' , 'd' ] ,
2233+ _categoriesMap : { 'a' : 0 , 'b' : 1 , 'c' : 2 , 'd' : 3 } ,
2234+ tickmode : 'linear' ,
2235+ tick0 : 0 ,
2236+ dtick : 1 ,
2237+ range : [ - 0.5 , 3.5 ]
2238+ } ;
2239+
2240+ // baseline
2241+ expect ( mockCalc ( ax ) ) . toEqual ( [ 'a' , 'b' , 'c' , 'd' ] ) ;
2242+ // reversed baseline
2243+ ax . range = [ 3.5 , - 0.5 ] ;
2244+ expect ( mockCalc ( ax ) ) . toEqual ( [ 'd' , 'c' , 'b' , 'a' ] ) ;
2245+
2246+ [ [ - 5 , - 1 ] , [ - 1 , - 5 ] , [ 5 , 10 ] , [ 10 , 5 ] ] . forEach ( function ( rng ) {
2247+ ax . range = rng ;
2248+ expect ( mockCalc ( ax ) . length ) . toBe ( 0 , rng ) ;
2249+ } ) ;
2250+ } ) ;
2251+
22292252 it ( 'should always start at year for date axis hover' , function ( ) {
22302253 var ax = {
22312254 type : 'date' ,
@@ -2321,10 +2344,8 @@ describe('Test axes', function() {
23212344 range : [ 1e200 , 2e200 ]
23222345 } ) ;
23232346
2324- // This actually gives text '-Infinity' because it can't
2325- // calculate the first tick properly, but since it's not going to
2326- // be able to do any better with the rest, we don't much care.
2327- expect ( textOut . length ) . toBe ( 1 ) ;
2347+ // with the fix for #1645 we're not even getting the '-Infinity' we used to :tada:
2348+ expect ( textOut . length ) . toBe ( 0 ) ;
23282349 } ) ;
23292350
23302351 it ( 'truncates at the greater of 1001 ticks or one per pixel' , function ( ) {
0 commit comments