Skip to content

Commit 58acd27

Browse files
Add new test to localize_test to handle new locale format parameters
1 parent f90efdc commit 58acd27

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

test/jasmine/tests/localize_test.js

+50
Original file line numberDiff line numberDiff line change
@@ -233,4 +233,54 @@ describe('localization', function() {
233233
.catch(failTest)
234234
.then(done);
235235
});
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+
});
236286
});

0 commit comments

Comments
 (0)