@@ -949,42 +949,51 @@ describe('dc.barChart', function () {
949
949
} ) ;
950
950
} ) ;
951
951
} ) ;
952
- describe ( 'with elasticX and x-axis padding' , function ( ) {
952
+ describe ( 'with elasticX and x-axis padding' , function ( ) {
953
953
var date = makeDate ( 2012 , 5 , 1 ) ;
954
954
beforeEach ( function ( ) {
955
-
956
955
var rows = [
957
- { x : date , y : 4 } ,
956
+ { x : date , y : 4 } ,
958
957
] ;
959
958
data = crossfilter ( rows ) ;
960
959
dimension = data . dimension ( function ( d ) {
961
- return d . x ;
960
+ return d . x ;
962
961
} ) ;
963
962
group = dimension . group ( ) . reduceSum ( function ( d ) {
964
- return d . y ;
963
+ return d . y ;
965
964
} ) ;
966
965
chart = dc . barChart ( '#' + id ) ;
967
966
chart . width ( 500 )
968
- . transitionDuration ( 0 )
969
- . x ( d3 . time . scale ( ) )
970
- . elasticY ( true ) . elasticX ( true )
971
- . dimension ( dimension )
972
- . group ( group )
967
+ . transitionDuration ( 0 )
968
+ . x ( d3 . time . scale ( ) )
969
+ . elasticY ( true ) . elasticX ( true )
970
+ . dimension ( dimension )
971
+ . group ( group ) ;
973
972
chart . render ( ) ;
974
973
} ) ;
975
- it ( 'should render the right xAxisMax/Min when no padding' , function ( ) {
974
+ // note: these tests assume that the bar width is not included in the
975
+ // chart width, so they should be broken when #792 is fixed
976
+ it ( 'should render the right xAxisMax/Min when no padding' , function ( ) {
976
977
expect ( chart . xAxisMin ( ) ) . toEqual ( date ) ;
977
978
expect ( chart . xAxisMax ( ) ) . toEqual ( date ) ;
978
- } )
979
- it ( 'should render the right xAxisMax/Min when 10 day padding' , function ( ) {
980
- chart . xAxisPadding ( 10 )
981
- let expectedStartDate = d3 . time . day . offset ( date , - 10 ) ;
982
- let expectedEndDate = d3 . time . day . offset ( date , 10 ) ;
983
- expect ( chart . xAxisMin ( ) ) . toEqual ( expectedStartDate ) ;
984
- expect ( chart . xAxisMax ( ) ) . toEqual ( expectedEndDate ) ;
985
979
} ) ;
986
-
987
- it ( 'should render the right ' )
980
+ it ( 'should render the right xAxisMax/Min when 10 day padding' , function ( ) {
981
+ chart . xAxisPadding ( 10 )
982
+ . render ( ) ;
983
+ var expectedStartDate = d3 . time . day . offset ( date , - 10 ) ;
984
+ var expectedEndDate = d3 . time . day . offset ( date , 10 ) ;
985
+ expect ( chart . xAxisMin ( ) ) . toEqual ( expectedStartDate ) ;
986
+ expect ( chart . xAxisMax ( ) ) . toEqual ( expectedEndDate ) ;
987
+ } ) ;
988
+ it ( 'should render the right xAxisMax/Min when 2 month padding' , function ( ) {
989
+ chart . xAxisPaddingUnit ( 'month' )
990
+ . xAxisPadding ( 2 )
991
+ . render ( ) ;
992
+ var expectedStartDate = d3 . time . month . offset ( date , - 2 ) ;
993
+ var expectedEndDate = d3 . time . month . offset ( date , 2 ) ;
994
+ expect ( chart . xAxisMin ( ) ) . toEqual ( expectedStartDate ) ;
995
+ expect ( chart . xAxisMax ( ) ) . toEqual ( expectedEndDate ) ;
996
+ } ) ;
988
997
} ) ;
989
998
describe ( 'with changing number of bars and elasticX' , function ( ) {
990
999
beforeEach ( function ( ) {
@@ -1034,7 +1043,6 @@ describe('dc.barChart', function () {
1034
1043
} ) ;
1035
1044
} ) ;
1036
1045
1037
-
1038
1046
describe ( 'with changing number of ordinal bars and elasticX' , function ( ) {
1039
1047
beforeEach ( function ( ) {
1040
1048
var rows1 = [
0 commit comments