@@ -1165,15 +1165,19 @@ describe('Test axes', function() {
1165
1165
1166
1166
it ( 'should validate inputs in respect to *day of week* pattern' , function ( ) {
1167
1167
layoutIn = {
1168
- xaxis : { type : 'date' , rangebreaks : [ { pattern : 'day of week' , bounds : [ '6.999 ' , '0' ] } ] } ,
1168
+ xaxis : { type : 'date' , rangebreaks : [ { pattern : 'day of week' , bounds : [ '6' , '0' ] } ] } ,
1169
1169
xaxis2 : { type : 'date' , rangebreaks : [ { bounds : [ 'Sunday' ] } ] } ,
1170
1170
xaxis3 : { type : 'date' , rangebreaks : [ { bounds : [ 'sun' , 'mon' , 'tue' ] } ] } ,
1171
1171
xaxis4 : { type : 'date' , rangebreaks : [ { pattern : 'day of week' , bounds : [ 1 , '-1' ] } ] } ,
1172
- xaxis5 : { type : 'date' , rangebreaks : [ { pattern : 'day of week' , bounds : [ 1 , '-.001 ' ] } ] } ,
1172
+ xaxis5 : { type : 'date' , rangebreaks : [ { pattern : 'day of week' , bounds : [ 1 , '-.25 ' ] } ] } ,
1173
1173
xaxis6 : { type : 'date' , rangebreaks : [ { pattern : 'day of week' , bounds : [ 1 , '7' ] } ] } ,
1174
- xaxis7 : { type : 'date' , rangebreaks : [ { pattern : 'day of week' , bounds : [ 1 , '6.999' ] } ] }
1174
+ xaxis7 : { type : 'date' , rangebreaks : [ { pattern : 'day of week' , bounds : [ 1 , '6.75' ] } ] } ,
1175
+ xaxis8 : { type : 'date' , rangebreaks : [ { pattern : 'day of week' , bounds : [ 1 , '' ] } ] } ,
1176
+ xaxis9 : { type : 'date' , rangebreaks : [ { pattern : 'day of week' , bounds : [ 1 , null ] } ] } ,
1177
+ xaxis10 : { type : 'date' , rangebreaks : [ { pattern : 'day of week' , bounds : [ 1 , false ] } ] } ,
1178
+ xaxis11 : { type : 'date' , rangebreaks : [ { pattern : 'day of week' , bounds : [ 1 , true ] } ] }
1175
1179
} ;
1176
- layoutOut . _subplots . xaxis . push ( 'x2' , 'x3' , 'x4' , 'x5' , 'x6' , 'x7' ) ;
1180
+ layoutOut . _subplots . xaxis . push ( 'x2' , 'x3' , 'x4' , 'x5' , 'x6' , 'x7' , 'x8' , 'x9' , 'x10' , 'x11' ) ;
1177
1181
supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
1178
1182
1179
1183
expect ( layoutOut . xaxis . rangebreaks [ 0 ] . enabled ) . toBe ( true , 'valid' ) ;
@@ -1185,34 +1189,44 @@ describe('Test axes', function() {
1185
1189
expect ( layoutOut . xaxis4 . rangebreaks [ 0 ] . enabled ) . toBe ( false , 'reject bound < 0' ) ;
1186
1190
expect ( layoutOut . xaxis5 . rangebreaks [ 0 ] . enabled ) . toBe ( false , 'reject bound < 0' ) ;
1187
1191
expect ( layoutOut . xaxis6 . rangebreaks [ 0 ] . enabled ) . toBe ( false , 'reject bound >= 7' ) ;
1188
- expect ( layoutOut . xaxis7 . rangebreaks [ 0 ] . enabled ) . toBe ( true , 'do not reject bound < 7' ) ;
1192
+ expect ( layoutOut . xaxis7 . rangebreaks [ 0 ] . enabled ) . toBe ( false , 'reject bound < 7 - not supported yet' ) ;
1193
+ expect ( layoutOut . xaxis8 . rangebreaks [ 0 ] . enabled ) . toBe ( false , 'reject blank string' ) ;
1194
+ expect ( layoutOut . xaxis9 . rangebreaks [ 0 ] . enabled ) . toBe ( false , 'reject null' ) ;
1195
+ expect ( layoutOut . xaxis10 . rangebreaks [ 0 ] . enabled ) . toBe ( false , 'reject false' ) ;
1196
+ expect ( layoutOut . xaxis11 . rangebreaks [ 0 ] . enabled ) . toBe ( false , 'reject true' ) ;
1189
1197
} ) ;
1190
1198
1191
1199
it ( 'should validate inputs in respect to *hour* pattern' , function ( ) {
1192
1200
layoutIn = {
1193
- xaxis : { type : 'date' , rangebreaks : [ { pattern : 'hour' , bounds : [ '23.999 ' , '0 ' ] } ] } ,
1201
+ xaxis : { type : 'date' , rangebreaks : [ { pattern : 'hour' , bounds : [ '24 ' , '1e-3 ' ] } ] } ,
1194
1202
xaxis2 : { type : 'date' , rangebreaks : [ { pattern : 'hour' , bounds : [ 1 ] } ] } ,
1195
1203
xaxis3 : { type : 'date' , rangebreaks : [ { pattern : 'hour' , bounds : [ 1 , 2 , 3 ] } ] } ,
1196
1204
xaxis4 : { type : 'date' , rangebreaks : [ { pattern : 'hour' , bounds : [ 1 , '-1' ] } ] } ,
1197
1205
xaxis5 : { type : 'date' , rangebreaks : [ { pattern : 'hour' , bounds : [ 1 , '-.001' ] } ] } ,
1198
1206
xaxis6 : { type : 'date' , rangebreaks : [ { pattern : 'hour' , bounds : [ 1 , '24.001' ] } ] } ,
1199
1207
xaxis7 : { type : 'date' , rangebreaks : [ { pattern : 'hour' , bounds : [ 1 , '23.999' ] } ] } ,
1200
- xaxis8 : { type : 'date' , rangebreaks : [ { pattern : 'hour' , bounds : [ 1 , '24' ] } ] }
1208
+ xaxis8 : { type : 'date' , rangebreaks : [ { pattern : 'day of week' , bounds : [ 1 , '' ] } ] } ,
1209
+ xaxis9 : { type : 'date' , rangebreaks : [ { pattern : 'day of week' , bounds : [ 1 , null ] } ] } ,
1210
+ xaxis10 : { type : 'date' , rangebreaks : [ { pattern : 'day of week' , bounds : [ 1 , false ] } ] } ,
1211
+ xaxis11 : { type : 'date' , rangebreaks : [ { pattern : 'day of week' , bounds : [ 1 , true ] } ] }
1201
1212
} ;
1202
- layoutOut . _subplots . xaxis . push ( 'x2' , 'x3' , 'x4' , 'x5' , 'x6' , 'x7' , 'x8' ) ;
1213
+ layoutOut . _subplots . xaxis . push ( 'x2' , 'x3' , 'x4' , 'x5' , 'x6' , 'x7' , 'x8' , 'x9' , 'x10' , 'x11' ) ;
1203
1214
supplyLayoutDefaults ( layoutIn , layoutOut , fullData ) ;
1204
1215
1205
1216
expect ( layoutOut . xaxis . rangebreaks [ 0 ] . enabled ) . toBe ( true , 'valid' ) ;
1206
- expect ( layoutOut . xaxis . rangebreaks [ 0 ] . bounds [ 0 ] ) . toBe ( '23.999' , 'do not cast float to int ' ) ;
1207
- expect ( layoutOut . xaxis . rangebreaks [ 0 ] . bounds [ 1 ] ) . toBe ( '0' , 'do not cast string to int ' ) ;
1217
+ expect ( layoutOut . xaxis . rangebreaks [ 0 ] . bounds [ 0 ] ) . toBe ( 24 , 'accept 24 ' ) ;
1218
+ expect ( layoutOut . xaxis . rangebreaks [ 0 ] . bounds [ 1 ] ) . toBe ( 0.001 , 'cast string to float ' ) ;
1208
1219
expect ( layoutOut . xaxis2 . rangebreaks [ 0 ] . enabled ) . toBe ( false , 'reject bounds.length < 2' ) ;
1209
1220
expect ( layoutOut . xaxis3 . rangebreaks [ 0 ] . enabled ) . toBe ( true , 'do not reject bounds.length > 2' ) ;
1210
1221
expect ( layoutOut . xaxis3 . rangebreaks [ 0 ] . bounds . length ) . toBe ( 2 , 'pick first two' ) ;
1211
1222
expect ( layoutOut . xaxis4 . rangebreaks [ 0 ] . enabled ) . toBe ( false , 'reject bound < 0' ) ;
1212
1223
expect ( layoutOut . xaxis5 . rangebreaks [ 0 ] . enabled ) . toBe ( false , 'reject bound < 0' ) ;
1213
1224
expect ( layoutOut . xaxis6 . rangebreaks [ 0 ] . enabled ) . toBe ( false , 'reject bound > 24' ) ;
1214
1225
expect ( layoutOut . xaxis7 . rangebreaks [ 0 ] . enabled ) . toBe ( true , 'do not reject bound <= 24' ) ;
1215
- expect ( layoutOut . xaxis8 . rangebreaks [ 0 ] . enabled ) . toBe ( true , 'do not reject 24' ) ;
1226
+ expect ( layoutOut . xaxis8 . rangebreaks [ 0 ] . enabled ) . toBe ( false , 'reject blank string' ) ;
1227
+ expect ( layoutOut . xaxis9 . rangebreaks [ 0 ] . enabled ) . toBe ( false , 'reject null' ) ;
1228
+ expect ( layoutOut . xaxis10 . rangebreaks [ 0 ] . enabled ) . toBe ( false , 'reject false' ) ;
1229
+ expect ( layoutOut . xaxis11 . rangebreaks [ 0 ] . enabled ) . toBe ( false , 'reject true' ) ;
1216
1230
} ) ;
1217
1231
} ) ;
1218
1232
0 commit comments