File tree 1 file changed +50
-0
lines changed
1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -233,4 +233,54 @@ describe('localization', function() {
233
233
. catch ( failTest )
234
234
. then ( done ) ;
235
235
} ) ;
236
+
237
+ it ( 'uses extraFormat to localize the autoFormatted x-axis date tick' , function ( done ) {
238
+ plot ( 'test' )
239
+ . then ( function ( ) {
240
+ // test format.month
241
+ expect ( firstXLabel ( ) ) . toBe ( 'Jan 2001' ) ;
242
+ return Plotly . update ( gd , { x : [ [ '2001-01-01' , '2001-02-01' ] ] } ) ;
243
+ } )
244
+ . then ( function ( ) {
245
+ // test format.dayMonth & format.year
246
+ expect ( firstXLabel ( ) ) . toBe ( 'Dec 312000' ) ;
247
+
248
+ return Plotly . update ( gd , { x : [ [ '2001-01-01' , '2001-01-02' ] ] } ) ;
249
+ } )
250
+ . then ( function ( ) {
251
+ // test format.dayMonthYear
252
+ expect ( firstXLabel ( ) ) . toBe ( '00:00Jan 1, 2001' ) ;
253
+
254
+ Plotly . register ( {
255
+ moduleType : 'locale' ,
256
+ name : 'test' ,
257
+ format : {
258
+ year : 'Y%Y' ,
259
+ month : '%Y %b' ,
260
+ dayMonth : '%-d %b' ,
261
+ dayMonthYear : '%-d %b %Y'
262
+ }
263
+ } ) ;
264
+
265
+ return Plotly . update ( gd , { x : [ [ '2001-01-01' , '2002-01-01' ] ] } ) ;
266
+ } )
267
+ . then ( function ( ) {
268
+ // test format.month
269
+ expect ( firstXLabel ( ) ) . toBe ( '2001 Jan' ) ;
270
+
271
+ return Plotly . update ( gd , { x : [ [ '2001-01-01' , '2001-02-01' ] ] } ) ;
272
+ } )
273
+ . then ( function ( ) {
274
+ // test format.dayMonth & format.year
275
+ expect ( firstXLabel ( ) ) . toBe ( '31 DecY2000' ) ;
276
+
277
+ return Plotly . update ( gd , { x : [ [ '2001-01-01' , '2001-01-02' ] ] } ) ;
278
+ } )
279
+ . then ( function ( ) {
280
+ // test format.dayMonthYear
281
+ expect ( firstXLabel ( ) ) . toBe ( '00:001 Jan 2001' ) ;
282
+ } )
283
+ . catch ( failTest )
284
+ . then ( done ) ;
285
+ } ) ;
236
286
} ) ;
You can’t perform that action at this time.
0 commit comments